db2 command not found -tvf - Plink in AIX vs. Linux

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Justin

    db2 command not found -tvf - Plink in AIX vs. Linux


    We have a simple shell script called testsp.sh (located at /home/
    userid)
    Within the shell script, the following command is called:
    db2 -tvf callsp.sql

    When the shell script is run in command line mode, it works as
    expected.
    and running db2 -tvf ... in command line it also works.

    The issue occurs when running using "plink"

    start plink -pw <pwduserid@db2_ serv02 /home/userid/testsp.sh

    The exact plink command worked with Linux but fails with AIX.

    The error: db2: command not found.

  • Jan M. Nelken

    #2
    Re: db2 command not found -tvf - Plink in AIX vs. Linux

    Justin wrote:
    We have a simple shell script called testsp.sh (located at /home/
    userid)
    Within the shell script, the following command is called:
    db2 -tvf callsp.sql
    >
    When the shell script is run in command line mode, it works as
    expected.
    and running db2 -tvf ... in command line it also works.
    >
    The issue occurs when running using "plink"
    >
    start plink -pw <pwduserid@db2_ serv02 /home/userid/testsp.sh
    >
    The exact plink command worked with Linux but fails with AIX.
    >
    The error: db2: command not found.
    >
    .... what is plink, what it does and why you think such command exists in
    Aix?

    Jan M. Nelken

    Comment

    • Lennart

      #3
      Re: db2 command not found -tvf - Plink in AIX vs. Linux

      Justin wrote:
      We have a simple shell script called testsp.sh (located at /home/
      userid)
      Within the shell script, the following command is called:
      db2 -tvf callsp.sql
      >
      When the shell script is run in command line mode, it works as
      expected.
      and running db2 -tvf ... in command line it also works.
      >
      The issue occurs when running using "plink"
      >
      start plink -pw <pwduserid@db2_ serv02 /home/userid/testsp.sh
      >
      The exact plink command worked with Linux but fails with AIX.
      >
      The error: db2: command not found.
      >
      Dont know plink, but if db2 cant be found its usually because
      environment is not setup properly. Tru sourcing db2profile in your
      script, I.e.

      .. ~<instanceowner >/sqllib/db2profile
      db2 connect to ...
      db2 -tvf callsp.sql
      ....

      /Lennart

      Comment

      • Justin

        #4
        Re: db2 command not found -tvf - Plink in AIX vs. Linux


        Plink is a utility to launch a unix session from dos. It is a sweet
        app.


        On May 14, 10:44 am, "Jan M. Nelken" <Unknown.U...@I nvalid.Domain>
        wrote:
        Justin wrote:
        We have a simple shell script called testsp.sh (located at /home/
        userid)
        Within the shell script, the following command is called:
        db2 -tvf callsp.sql
        >
        When the shell script is run in command line mode, it works as
        expected.
        and running db2 -tvf ... in command line it also works.
        >
        The issue occurs when running using "plink"
        >
        start plink -pw <pwduserid@db2_ serv02 /home/userid/testsp.sh
        >
        The exact plink command worked with Linux but fails with AIX.
        >
        The error: db2: command not found.
        >
        ... what is plink, what it does and why you think such command exists in
        Aix?
        >
        Jan M. Nelken- Hide quoted text -
        >
        - Show quoted text -

        Comment

        • Justin

          #5
          Re: db2 command not found -tvf - Plink in AIX vs. Linux


          Lennart,

          You are correct. Added...
          .. /home/userid/sqllib/db2profile
          to the script and everything is fine.

          Seems only to be an issue with AIX not Linux.

          -Kevin

          Linux: Developed by the people for the people; AIX: Developed by IBM
          - for IBM (not for the people)

          On May 14, 11:11 am, Lennart <erik.lennart.j ons...@gmail.co mwrote:
          Justin wrote:
          We have a simple shell script called testsp.sh (located at /home/
          userid)
          Within the shell script, the following command is called:
          db2 -tvf callsp.sql
          >
          When the shell script is run in command line mode, it works as
          expected.
          and running db2 -tvf ... in command line it also works.
          >
          The issue occurs when running using "plink"
          >
          start plink -pw <pwduserid@db2_ serv02 /home/userid/testsp.sh
          >
          The exact plink command worked with Linux but fails with AIX.
          >
          The error: db2: command not found.
          >
          Dont know plink, but if db2 cant be found its usually because
          environment is not setup properly. Tru sourcing db2profile in your
          script, I.e.
          >
          . ~<instanceowner >/sqllib/db2profile
          db2 connect to ...
          db2 -tvf callsp.sql
          ...
          >
          /Lennart- Hide quoted text -
          >
          - Show quoted text -

          Comment

          • Dave Hughes

            #6
            Re: db2 command not found -tvf - Plink in AIX vs. Linux

            Justin wrote:
            >
            Plink is a utility to launch a unix session from dos. It is a sweet
            app.
            More specifically, it's part of the PuTTY suite on Windows[1]. Plink[2]
            is a command line telnet/rsh/ssh client. Very handy indeed.

            [snip]


            [1] http://www.chiark.greenend.org.uk/~sgtatham/putty/
            [2] http://the.earth.li/~sgtatham/putty/...er7.html#plink

            Dave.

            --

            Comment

            • Dave Hughes

              #7
              Re: db2 command not found -tvf - Plink in AIX vs. Linux

              Justin wrote:
              You are correct. Added...
              . /home/userid/sqllib/db2profile
              to the script and everything is fine.
              >
              Seems only to be an issue with AIX not Linux.
              That's strange. At least under v8 (may be different with v9),
              db2profile had to be manually sourced by users wishing to access DB2,
              or added to the profile so it got sourced automatically on login, under
              both Linux and AIX (certainly I've had to manually add it to bashrc for
              various users on my Linux server).

              IIRC, the GUI setup adds it automatically to the instance owner's
              profile, unless you use the manual (non-GUI) setup in which case it
              still needs adding manually.


              Dave.

              --

              Comment

              • Knut Stolze

                #8
                Re: db2 command not found -tvf - Plink in AIX vs. Linux

                Dave Hughes wrote:
                Justin wrote:
                >
                >>
                >Plink is a utility to launch a unix session from dos. It is a sweet
                >app.
                >
                More specifically, it's part of the PuTTY suite on Windows[1]. Plink[2]
                is a command line telnet/rsh/ssh client. Very handy indeed.
                Does it initiate a login shell? If not, then ~/.profile is not read and,
                thus, the DB2 environment not set up because ~/sqllib/db2profile is not
                sourced.

                --
                Knut Stolze
                DB2 z/OS Utilities Development
                IBM Germany

                Comment

                • Darin McBride

                  #9
                  Re: db2 command not found -tvf - Plink in AIX vs. Linux

                  Dave Hughes wrote:
                  Justin wrote:
                  >
                  >You are correct. Added...
                  >. /home/userid/sqllib/db2profile
                  >to the script and everything is fine.
                  >>
                  >Seems only to be an issue with AIX not Linux.
                  >
                  That's strange. At least under v8 (may be different with v9),
                  db2profile had to be manually sourced by users wishing to access DB2,
                  or added to the profile so it got sourced automatically on login, under
                  both Linux and AIX (certainly I've had to manually add it to bashrc for
                  various users on my Linux server).
                  >
                  IIRC, the GUI setup adds it automatically to the instance owner's
                  profile, unless you use the manual (non-GUI) setup in which case it
                  still needs adding manually.
                  Actually, db2icrt adds it - so it shouldn't matter whether you use the GUI
                  or not to create the instance. The instance owner should always get it, if
                  the instance owner even has a .profile/.login/.bashrc to modify.

                  Comment

                  • Dave Hughes

                    #10
                    Re: db2 command not found -tvf - Plink in AIX vs. Linux

                    Knut Stolze wrote:
                    Dave Hughes wrote:
                    >
                    Justin wrote:
                    >
                    Plink is a utility to launch a unix session from dos. It is a
                    sweet >app.

                    More specifically, it's part of the PuTTY suite on Windows[1].
                    Plink[2] is a command line telnet/rsh/ssh client. Very handy indeed.
                    >
                    Does it initiate a login shell? If not, then ~/.profile is not read
                    and, thus, the DB2 environment not set up because ~/sqllib/db2profile
                    is not sourced.
                    Interesting point. PuTTY itself usually starts a login shell
                    (naturally). However, when called with a command line to execute, plink
                    DOES NOT start a login shell:

                    C:\>plink -ssh dave@nibbler echo $0
                    bash

                    (if it were a login shell, it ought to return -bash instead of bash).
                    If called with no command to execute (i.e. in interactive mode), plink
                    accepts input from stdin. In this case, it (unsurprisingly ) DOES start
                    a login shell:

                    C:\>echo echo $0 | plink -ssh dave@nibbler
                    -bash

                    Despite the SSH documentation stating otherwise ("If command is
                    specified, it is executed on the remote host instead of a login shell")
                    it appears this is the opposite behaviour of the OpenSSH client under
                    Linux:

                    $ ssh dave@nibbler "echo $0"
                    -bash

                    $ echo 'echo $0' | ssh dave@nibbler
                    -bash

                    So, I guess the moral of the story is that if one wishes to run scripts
                    that access DB2 remotely over SSH, to ensure compatibility with
                    different SSH clients which may not start a full login shell, one
                    should ensure the script on the server sources
                    ~db2inst1/sqllib/db2profile before attempting to access DB2.


                    Cheers,

                    Dave.

                    --

                    Comment

                    • Justin

                      #11
                      Re: db2 command not found -tvf - Plink in AIX vs. Linux


                      Using Linux as the OS, we did not have an issue with DB2 version 8 or
                      9.
                      With AIX, we only use DB2 version 9 and had the issue.

                      I am really new to DB2 (couple months) - so my knowledge of profile
                      management is near zero

                      :)

                      On May 14, 3:32 pm, "Dave Hughes" <d...@waveform. plus.comwrote:
                      Justin wrote:
                      You are correct. Added...
                      . /home/userid/sqllib/db2profile
                      to the script and everything is fine.
                      >
                      Seems only to be an issue with AIX not Linux.
                      >
                      That's strange. At least under v8 (may be different with v9),
                      db2profile had to be manually sourced by users wishing to access DB2,
                      or added to the profile so it got sourced automatically on login, under
                      both Linux and AIX (certainly I've had to manually add it to bashrc for
                      various users on my Linux server).
                      >
                      IIRC, the GUI setup adds it automatically to the instance owner's
                      profile, unless you use the manual (non-GUI) setup in which case it
                      still needs adding manually.
                      >
                      Dave.
                      >
                      --

                      Comment

                      Working...