If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to connect from Windows to a db2 db sitting on UNIX

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-01-12, 11:36
cti_depaul cti_depaul is offline
Registered User
 
Join Date: Feb 2012
Posts: 2
How to connect from Windows to a db2 db sitting on UNIX

Hi ALL,

I need to connect, from windows, to a db2 database sitting on a UNIX server, run a few commands against the server as well as the database and save the output to a file.

I created a batch file test.bat and it contains the following:
Code:
@ECHO OFF start SecureCRT.exe /SSH2 /L <login_name> /PASSWORD <password> <IP>
Running this batch file would connect me to the server. However I still need to connect to the database and run my commands.
I tried adding the following to the batch, but once it connects to the server, it ignores the rest.

Code:
@ECHO OFF start SecureCRT.exe /SSH2 /L <login_name> /PASSWORD <password> <IP>
db2 list applications > temp.out
db2 connect to <database> >> temp.out
db2 SELECT * FROM SYSIBM.DUAL >> temp.out

Even if I create two separate files: one to connect to the server and add a line in it to run the second file, where it connects to the database. It didn't work.

test.bat
Code:
@ECHO OFF start SecureCRT.exe /SSH2 /L <login_name> /PASSWORD <password> <IP>
test2.bat
test2.bat
Code:
db2 list applications > temp.out
db2 connect to <database> >> temp.out
db2 SELECT * FROM SYSIBM.DUAL >> temp.out
I'm on WindowsXP. The server is UNIX 5.3 and the database is DB2 9.7

Any idea on how to proceed would be much appreciated!!
Reply With Quote
  #2 (permalink)  
Old 02-01-12, 11:44
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
do you have a windows db2 client installed
securecrt is an ssh client
try the native commands to connect to db2
list applications is only possible with attach to instance not with connect
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 02-01-12, 11:51
cti_depaul cti_depaul is offline
Registered User
 
Join Date: Feb 2012
Posts: 2
Yes I have the client installed.
Reply With Quote
  #4 (permalink)  
Old 02-01-12, 12:53
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by cti_depaul View Post
Yes I have the client installed.
You don't need an ssh session to execute DB2 commands and statements, just launch db2cmd and run your 2nd script in it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On