Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2011
    Posts
    7

    Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    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)

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  5. #5
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •