stderr quicky question [Archive] - C Board

PDA

View Full Version : stderr quicky question


HOWY
07-05-2002, 09:35 AM
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

raimo
07-05-2002, 09:52 AM
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.