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 > db2 clp over ssh

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-10-11, 11:55
emosms emosms is offline
Registered User
 
Join Date: Mar 2011
Posts: 7
db2 clp over ssh

Hi,
I am trying to connect to a database instance on a remote server over ssh connection.
-establishing the connection with a .bat script (local machine: winXP)
Code:
plink user@hostIP -pw pass -m local_script.sh
pause
-the file local_script.sh
Code:
db2start
db2 connect to databaseInstance user userName using pass
But, I get the following:
Code:
sh: db2start: not found
sh: db2: not found
If I establish a connection via ssh, then type into the ssh console the commands 'db2start' and 'db2 bla-bla..' - it is all working.
Not working with the script though.

Any Ideas?
Best Regards
Reply With Quote
  #2 (permalink)  
Old 04-10-11, 15:47
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Not sure if this works from Windows, but you might try running the db2profile at the top of your script. It is usually located in the <DB2_instance_home>/sqllib directory.

The command is:
. db2profile

Note that "dot" has a space after it.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 04-11-11, 04:54
emosms emosms is offline
Registered User
 
Join Date: Mar 2011
Posts: 7
db2 over ssh

thxs.
db2 is installed on ubuntu server 10 (remote machine)
db2start and db2 not working, cause I have to supply full paths to
db2start/stop and db2 into the local .sh script stored on xp

Code:
./sqllib/adm/db2start # assumming pwd is the db2/linux user home dir
cd /
./opt/ibm/db2/V9.7/bin/db2 connect to tuning
Btw, db2 works in the ubuntu box console,
and it seems to work over ssh if I set explicitly the path to db2 in linux profile (eventhough it finds it somehow from ubuntu's console)

Now I am trying to run remotely a python script.
It is the same situation with the python imports:

Code:
import ibm_db
import sys
and

Code:
sh: import not found
sh: import not found
I supplied the path:
Code:
import ./usr/include/sys
and it does not complain, but where to find ibm_db on linux ????

>>>import ibm_db # on linux goes without complaint, but the 'find' bash command does not find any 'ibm_db'

where to find ibm_db on ubuntu10.10 (it is the python db2 driver)
Reply With Quote
  #4 (permalink)  
Old 04-11-11, 07:33
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
It could be the case that ssh in your script doesn't start a so-called "login shell", so the environment is not set up in the same way as a regular "ssh". You can verify this by dumping all environment variables using "export" or something similar in the different situations that work vs. do not work.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 04-11-11, 10:27
emosms emosms is offline
Registered User
 
Join Date: Mar 2011
Posts: 7
syncro

Just realized that I cannot refer back to sql scripts from the locally executed .sh or python scripts.
Once they get to the remote shell they would ask for scripts relative to the pwd over there, so I am gonna need them uploaded there.
So, this time not only paths will be confused, but the actuall script won't be there at all..
# Not very smart, shouldn't took me that long to find it out
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