473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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
6 16497
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: rhjaisingh | last post by:
Folks, I need to create a batch file that will do the following - Establish a DB2 instance Connect to a certain database Get data using an sql and output it to a file So, this is what I...
0
by: wb5plj | last post by:
Hi I am having a problem passing some sql to the db2cmd via ant. This is very confusing as I am doing this exact thing elseware with no problem (just differant sql, and I have verified the sql is...
1
by: udbadmin | last post by:
Where do you get examples for running db2 udb commands from db2cmd command line editor. Any good sites ...? Need help with db2cmd commands - How to connect to the database using db2cmd? How to...
5
by: Neil Chambers | last post by:
Hi All, I'm looking to see if it's feasible to use the SortObjectCommand included in the Microsoft.Powershell.Commands assembly. I have a Dictionary Dictionary<string, intd = new...
3
by: =?Utf-8?B?VGhvbWFzIFcuIEJyb3du?= | last post by:
1. Is there a dedicated discussion group for Windows Powershell? I couldn't find one, but that doesn't necessarily mean there isn't :-) 2. I'm just starting in on learning to use Powershell and...
0
by: DeepthiSem | last post by:
Hi Everyone I have an issue in running the DB2 command script using Batch file from Windows application. From my application i am calling the batch file which inturn runs the Db2cmd prompt . ...
2
by: Shivakumar | last post by:
Friends, Can anyone help me how to use DB2 utilities like IMPORT/LOAD in ASP scripts ?
2
by: rcook349 | last post by:
I'm trying to automate our builds and publishes of our Windows application (deployed to a website via ClickOnce). I'm getting close, I think, on the commands I need to execute. However, how do...
1
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i read the MS kb: Using Exchange Management Shell Commands With Managed Code http://msdn.microsoft.com/en-us/library/bb332449.aspx how ever i'm getting "{"No Windows PowerShell Snap-ins are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.