Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557

    Unanswered: db2look output issue

    I am working on a script that is based on the parm will generate a DDL using db2look. Problem I am having is I do not want anything showing up on the screen while db2look is running.

    I have found a solution, but it makes no sence to me what so ever. here is where I am looking out for you folks to help me understand why it is doing what it is doing.

    Here is what I am getting:

    1. Running db2look piping it out to a file
    db2look -d dbname -z schema -t ADVISE_INDEX -e -nofed -noview > x
    -- No userid was specified, db2look tries to use Environment variable USER
    -- USER is: mmmmmm
    -- Specified SCHEMA is: schema
    -- The db2look utility will consider only the specified tables
    -- Creating DDL for table(s)

    Return code for this command is 0
    DDL Information going to a file, lines with '--' are going to my screen.

    2. Now I am going to try to send std out to a file and not a screen

    db2look -d dbname -z schema -t ADVISE_INDEX -e -nofed -noview > x 1>xx
    -- No userid was specified, db2look tries to use Environment variable USER
    -- USER is: mmmmmm
    -- Specified SCHEMA is: schema
    -- The db2look utility will consider only the specified tables
    -- Creating DDL for table(s)

    Return code is still a 0
    However, as expected my x file is empty and all of the info is in the xx file. But garbage still went to the screen.

    3. My fingers did their own walking and wrote this

    db2look -d fctdbp -z uszaqk3 -t ADVISE_INDEX -e -nofed -noview >x 2>xx

    Return code is still a 0
    This gave me exactly what I need. DDL into a file, garbage in a dumpster.

    Here is where my dilemma. Why all those lines with '--' are treated as an error While return code is still a BIG FAT ZERO? I would have never guessed it.

    BTW. I am going to run sed command to clean up garbage file and then run a check on it. If it is empty, then there were no errors, if it is not empty...well, you guessed.

    Thank you and remember. It is Friday and it is 5pm someplace. But don't ignore my question
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  2. #2
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,367
    but lines that begin with '--' are just comments, not errors.

  3. #3
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    He means that those messages are being written to stderr and not stdout as one would expect. Why IBM chose to do that is beyond me. You will have to ask them as to their reasoning.

    Andy

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    This is standard practice to write the "payload" output to stdout and diagnostic messages to stderr so as not to mix two types of information. Many unix utilities work that way.
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    Bella, Andy is right on the money on what I meant. Bella, can you go smack someone over there for me?

    Nick, if you are correct, then it is madness. If I haven't discovered that it is putting -- into the stderr and was performing an error check. It would be alarming on every entree even so there was no problem.

    Not doubting you, but can you please provide some kind of document that talks about it. I have been reading UNIX book all day on it and haven't found a single references on this practice.

    BTW. It does write this junk to stdout anyway.
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  6. #6
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,367
    I think I got it now. You expect stderr to return a non-zero RC if the file contains something. If I specify a non-existing db name, then the RC is non-zero and the file contains the same comments plus the error message.

  7. #7
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by Cougar8000

    Nick, if you are correct, then it is madness.
    If you say so.

    Shell exit code is for status checks. Different output streams are used to separate program main output and diagnostic messages.

    Quote Originally Posted by Cougar8000
    Not doubting you, but can you please provide some kind of document that talks about it.
    Certainly. Amazon.com: Unix Programming Environment (Prentice-Hall Software Series) (9780139376818): Brian W. Kernighan, Rob Pike: Books
    ---
    "It does not work" is not a valid problem statement.

  8. #8
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    I will get this book, but mean while. Following what you are saying dashes should only go to stderr, why do they show up in stdout as well?
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  9. #9
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    The default stream for stderr goes to the console, unless you redirect it with 2> ...
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  10. #10
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    Knut, I understand and know this. My point is. If dashes are treated as stderr, why do they still show up in stdout even so I do redirect it with 2>

    This tells me that they are treated as stdout as well as stderr. And that is what drives me nuts I have enough problems my own split personality
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

Posting Permissions

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