Saturday, March 21, 2009

Don't forget to redirect standard error for debugging

Some programs print the error messages to the standard error instead of standard output. The trick is on a computer system, they both show up on the screen.

If you redirect the program's output to a file then examine the file later for troubleshooting, you may not find any error in the file. Most likely you run following from the command line.

cmd > file

The above command line only redirect the standard output to the file. To redirect both standard output and standard error to the file, run the following from the command line.

cmd > file 2>&1

No comments: