467,202 Members | 1,018 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,202 developers. It's quick & easy.

Run DB2CMD commands through PowerShell

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
  • viewed: 15127
Share:
6 Replies
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
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
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
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
Hi Jan,

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

Cheers.

Jul 12 '07 #6
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.

Similar topics

7 posts views Thread by rhjaisingh@gmail.com | last post: by
reply views Thread by wb5plj@gmail.com | last post: by
5 posts views Thread by Neil Chambers | last post: by
3 posts views Thread by =?Utf-8?B?VGhvbWFzIFcuIEJyb3du?= | last post: by
2 posts views Thread by Shivakumar | last post: by
1 post views Thread by =?Utf-8?B?YXVsZGg=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.