Thread: stderr quicky question

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    12

    Question stderr quicky question

    For example when I am directing a program's output to a file and then I look to that file I will be able to see the exact output that was redirected from stout to this file... Now if a program spits the output to this file and spits out a strerr error, how can I redirect that strerr so it doesn't print on the screen and yet I can check it out also...
    for example
    prog A spits its output to a file AA
    prog B spits its output to a file BB and spits out an error message on the screen...
    SO:
    if [ cmp AA solution_file ]; and if correct, i.e. no stderr screen-print I can handle it easily, that is I consider it CORRECT...but

    if [ cmp BB solution_file ]; I need to distinguish somehow that this comparison of files is in fact (physically) correct but it additionally generates a stderr message (that I need to hide from the screen) and I need to handle this BB as WRONG
    How do I redirect stderr, and how can I check for it? Any help is greatly appreciated...
    Thank you
    HOWY

  2. #2
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    For example, when I start my X server, I redirect the messages and error messages to a file called ~/xauth/xlog:

    startx >~/xauth/xlog 2>&1 &

    2> redirects from error stream
    &1 means the last mentioned place to output.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fprintf to stderr crash programs
    By jlai in forum Windows Programming
    Replies: 2
    Last Post: 04-12-2005, 08:51 AM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM