By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,586 Members | 2,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,586 IT Pros & Developers. It's quick & easy.

Run DB2CMD commands through PowerShell

P: n/a
Does anyone have an idea what it takes to administer DB2 through
PowerShell? I want to write some scripts to automate my common DB2
management tasks and I'd really like to be able to use PowerShell for
that scripting, but I can't find a way to run DB2 comands.

I've tried
db2cmd /w
db2cmd /w /i
db2cmd /i (this one got me the closest)
db2clpex (looked promising but not so helpfu)

It'd really be nice if there were some way I could just register
whatever environment variables and whatever else is needed right
inside my PowerShell session - that would be ideal. Anyone know how
to do that?

Thanks,

Mesan

Jul 10 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Mesan wrote:
Does anyone have an idea what it takes to administer DB2 through
PowerShell? I want to write some scripts to automate my common DB2
management tasks and I'd really like to be able to use PowerShell for
that scripting, but I can't find a way to run DB2 comands.
It is relatively very simple:

Set environment variable DB2CLP to string **$$** and you can use
PowerShell for Db2 commands.
Jan M. Nelken
Jul 10 '07 #2

P: n/a
On Jul 10, 9:41 am, "Jan M. Nelken" <Unknown.U...@Invalid.Domain>
wrote:
Mesan wrote:
Does anyone have an idea what it takes to administer DB2 through
PowerShell? I want to write some scripts to automate my common DB2
management tasks and I'd really like to be able to use PowerShell for
that scripting, but I can't find a way to run DB2 comands.

It is relatively very simple:

Set environment variable DB2CLP to string **$$** and you can use
PowerShell for Db2 commands.

Jan M. Nelken
Please forgive me, I'm sure I'm making a stupid mistake. Here's what
I tried:

PSset %DB2CLP% **$$**
PSdb2 connect to mydb
DB21061E Command Line Environment not initialized.
PS>
Just how did you mean for me to set that environment variable?

Thanks again for your patience,

Mesan

Jul 10 '07 #3

P: n/a
On Jul 10, 10:14 am, Mesan <935m...@gmail.comwrote:
On Jul 10, 9:41 am, "Jan M. Nelken" <Unknown.U...@Invalid.Domain>
wrote:
Mesan wrote:
Does anyone have an idea what it takes to administer DB2 through
PowerShell? I want to write some scripts to automate my common DB2
management tasks and I'd really like to be able to use PowerShell for
that scripting, but I can't find a way to run DB2 comands.
It is relatively very simple:
Set environment variable DB2CLP to string **$$** and you can use
PowerShell for Db2 commands.
Jan M. Nelken

Please forgive me, I'm sure I'm making a stupid mistake. Here's what
I tried:

PSset %DB2CLP% **$$**
PSdb2 connect to mydb
DB21061E Command Line Environment not initialized.
PS>

Just how did you mean for me to set that environment variable?

Thanks again for your patience,

Mesan
You're a genius! I found some help on using environment variables in
powershell and it worked like a champ! Thanks - I just wonder why I
was unable to find that tip elsewhere - where did you learn that?

For anyone else reading the post - try this:

PSset-item -path env:DB2CLP -value "**$$**"
PSdb2 connect to mydb
.... it works!

Awesome - thanks a ton.

Mesan

Jul 10 '07 #4

P: n/a
Mesan wrote:
Just how did you mean for me to set that environment variable?

Thanks again for your patience,
One way would be to set it once in

<My Computer(right mouse click to get <Properties>, click on
<Advancedtab, then click on <Environment Variables(bottom button).

Under <System Variablesclick <Newand fill form with:

Variable name DB2CLP
Variable value **$$**
This works with DB2 V9.*, for users of DB2 V8.* there is much less
elegant solution available as well.
Jan M. Nelken
Jul 10 '07 #5

P: n/a
Hi Jan,

If you get around to posting the V8 solution I'd find it useful.

Cheers.

Jul 12 '07 #6

P: n/a
gi*******************@yahoo.com wrote:
If you get around to posting the V8 solution I'd find it useful.
For DB2 V8 follow those relatively simple 3 steps:
1. Find out process id (PID) if the shell process (CMD.EXE) - using Task
Manager, pslist.exe from Sysinternals or similliar tools;

2. Get db2ntclp.exe from IBM DB2 Support - specify your db2level; Run
db2ntclp command using PID of the CMD.EXE as argument;

3. Output of the db2ntclp command will tell you the value you should set
environment variable DB2CLP in the *same* CMD.EXE session whose PID you
used in step 1.
Jan M. Nelken
Jul 16 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.