Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does wget output to stderr rather than stdout?

After 30mins of futile attempt to capture the output of wget, I figured out that the program writes to stderr rather than the stdout. Searching in web and stack-overflow reveals this to be a well-known fact.

Any idea why is this so?

like image 839
BiGYaN Avatar asked Oct 25 '12 10:10

BiGYaN


People also ask

How do I redirect wget output?

The wget command outputs the document content in a separate file by default. However, we can use the –output-document (-O) option to redirect the content to a file of our choice. As a particular use case, if we use – as the file, it directs the content to stdout.

Why are stdout and stderr separate?

So stdout by design is for data in a pipe, stderr is for errors or other messages to the user.

Should logs go to stderr or stdout?

Only error logs should go to stderr. This is a pretty common convention supported by the 12factor design principles and the original intent behind io streams in operating systems. With all logs dumped to stderr, it's significantly more difficult to sift through output from using pipes.

What is redirecting stderr to stdout?

The regular output is sent to Standard Out (STDOUT) and the error messages are sent to Standard Error (STDERR). When you redirect console output using the > symbol, you are only redirecting STDOUT. In order to redirect STDERR, you have to specify 2> for the redirection symbol.


1 Answers

It's well known, because it's in the manual.

Reporting messages on stderr is common, because messages are separated from regular output on stdout. This is useful when you combine several tools with a pipe. In this case it would be bad, when regular output and diagnostic messages were mixed up.

like image 107
Olaf Dietsche Avatar answered Oct 18 '22 18:10

Olaf Dietsche