Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2012
    Posts
    2

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

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    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
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Feb 2012
    Posts
    2
    Yes I have the client installed.

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.

Posting Permissions

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