473,775 Members | 2,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16576
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...@I nvalid.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...@I nvalid.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(botto m 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.co m 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
21600
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 have done in my test.cmd file
0
4014
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 valid) but in this one I am having problems. Any time I run this I get the folowing message from the db2 clp window that opens up. SQL0104N An unexpected token "SET" was found following "<identifier>". Expected tokens may include: "NEW". ...
1
7218
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 check what alias are there? How to change the database password for the id? How to check who all are connected to the database?
5
2611
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 Dictionary<string, int>(); d = new int;
3
2679
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 doing so by slowly (very slowly) attempting to port some existing CMD and Perl scripts. I'm blocked right now on something that should be very simple (I would think)... I want to use SQLCMD to issue a query and parse/format the return string....
0
1130
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 . After starting the Bacth file process, the windows application is made to wait using the Thread.sleep() method untill the DB2 commands are executed completly. Once the Batch file starts running the Db2command in the Db2command prompt window my UI...
2
1685
by: Shivakumar | last post by:
Friends, Can anyone help me how to use DB2 utilities like IMPORT/LOAD in ASP scripts ?
2
5628
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 I put these commands in some sort of executable file? I thought at first a VBScript file (Windows script), but from what I'm reading that is old techology. A script in PowerShell? Not too familiar with this?
1
3142
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 available for version 1."}" exception when i try to call PSSnapInInfo info = rc.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapEx);
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10046
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9915
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5358
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4014
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.