1.

Solve : Stderr output?

Answer»

Hi all,
im writing a simple BATCH file which echo a statement to an output file and for some REASON if path for the output file is not available, I want the error to be sent to another file.
My batch file script looks like this.

echo test > "path for output file " 2> "C:\test\output.err"

When I run above batch file it fails with error "The system cannot find the path specified." which is fine, however I want to capture this error and send it to C:\test\output.err which is not happening .
Can someone shed light on this?First, did you read this?
https://support.microsoft.com/en-us/kb/110930
Redirecting Error Messages from Command PROMPT: STDERR/STDOU

Quote

When redirecting output from an application using the ">" 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.

Read the article for more details.multiple redirection operators specified this way only work on a single command; that is, in this case, the command is redirecting the standard output and standard error of the "echo test"; the redirection to standard error is not redirecting the standard error of the output from the redirection of the standard output. (Now there is a tongue twister...)

You need to separate it like so:

Code: [Select](echo test > "path for output file ") 2> "C:\test\output.err"

This way you are saying to redirect the output of "echo test" to a file, and then redirecting the standard error of that redirection itself to another file.BC_Programmer is right.Started helping the user on destiny about an hour before they posted here.
http://www.dostips.com/forum/viewtopic.php?f=3&t=7439 Quote from: Squashman on September 28, 2016, 10:51:24 PM
Started helping the user on destiny about an hour before they posted here.
http://www.dostips.com/forum/viewtopic.php?f=3&t=7439

Doesn't it get annoying!


Discussion

No Comment Found