You are currently offline, waiting for your internet to reconnect

Redirecting Error Messages from Command Prompt: STDERR/STDOUT

Support for Windows XP has ended

Microsoft ended support for Windows XP on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

Support for Windows Server 2003 ended on July 14, 2015

Microsoft ended support for Windows Server 2003 on July 14, 2015. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

This article was previously published under Q110930
SUMMARY
When redirecting output from an application using the ">" symbol, errormessages still print to the screen. This is because error messages areoften sent to the Standard Error stream instead of the Standard Out stream.

Output from a console (Command Prompt) application or command is often sentto two separate streams. The regular output is sent to Standard Out(STDOUT) and the error messages are sent to Standard Error (STDERR). Whenyou redirect console output using the ">" symbol, you are only redirectingSTDOUT. In order to redirect STDERR you have to specify "2>" for theredirection symbol. This selects the second output stream which is STDERR.

EXAMPLE

The command "dir file.xxx" (where file.xxx does not exist) will display thefollowing output:
Volume in drive F is Candy Cane Volume Serial Number is 34EC-0876

File Not Found
If you redirect the output to the NUL device using "dir file.xxx > nul",you will still see the error message:
File Not Found
To redirect the error message to NUL, use the following command:
   dir file.xxx 2> nul
Or, you can redirect the output to one place, and the errors to another.
   dir file.xxx > output.msg 2> output.err
You can print the errors and standard output to a single file by using the"&1" command to redirect the output for STDERR to STDOUT and then sendingthe output from STDOUT to a file:
   dir file.xxx 1> output.msg 2>&1
Properties

Article ID: 110930 - Last Review: 02/20/2007 03:34:39 - Revision: 3.3

  • Microsoft Windows NT Advanced Server 3.1
  • Microsoft Windows NT Workstation 3.1
  • Microsoft Windows NT Advanced Server 3.1
  • Microsoft Windows NT Workstation 3.51
  • Microsoft Windows NT Workstation 4.0 Developer Edition
  • Microsoft Windows XP Professional
  • Microsoft Windows Server 2003, Standard Edition (32-bit x86)
  • Microsoft Windows 2000 Professional Edition
  • kbusage KB110930
Feedback
" symbol, error messages still print to the screen. This is because error messages are often sent to the Standard Error stream instead of the Standard Out stream. Output from a console (Command..." />
" symbol, error messages still print to the screen. This is because error messages are often sent to the Standard Error stream instead of the Standard Out stream. Output from a console (Command..." />
> html>icrosoft.com/ms.js'" + "'><\/script>"); tml>