Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    72

    Unanswered: Unable to run several db2pd commands froma script file. Is my syntax correct?

    Hi all,

    I need to be able to execute several db2pd commands from a file such as lockinfo.sql. I have the following db2pd commands in this file:
    Begin file content:
    db2 connect to fsnst2dw user db2inst1 using db2grp1;
    db2pd -db fsnst2dw -locks wait showlocks > db2pd_out1.txt;
    db2pd -db fsnst2dw -transaction > db2pd_out2.txt;
    db2pd -agents > db2pd_out3.txt;
    db2pd -applications > db2pd_out4.txt;
    db2pd -db fsnst2dw -dynamic > db2pd_out5.txt;
    @
    End file content:
    When I try to run the script file as "db2 -td@ -f lockinfo.sql", I get the following errors...

    SQL0104N An unexpected token "db2" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "SELECT". SQLSTATE=42601

    DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0104N An unexpected token "-db fsnst2dw -locks wait showlocks" was found following "db2pd ". Expected tokens may include: "<space>". SQLSTATE=42601

    Can someone help with the correct method/syntax to make this work?

    Thanks aplenty!

  2. #2
    Join Date
    Jun 2006
    Posts
    471
    if this is executed with db2 -tf you can only db2 commands in this file without the db2 prefix. o/s commands or other db2 utilities as db2pd are not allowed
    it should be executed as a shell script and in that case have the db2 prefix
    Best Regards, Guy Przytula
    DB2 UDB LUW certified V6/7/8

  3. #3
    Join Date
    Mar 2007
    Posts
    72
    Thank you Guy. Could you plug in how you would turn the commands into a shell script? Scripting is not my forte (yet!)...

    Thanks

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by pagwu
    Could you plug in how you would turn the commands into a shell script?
    Not sure what "plug in" means in this context, but a shell script is simply a sequence of OS commands; you turn commands into a script by putting those commands in a text file.
    ---
    "It does not work" is not a valid problem statement.

Posting Permissions

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