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.
经过30分钟徒劳的尝试捕获wget的输出后,我发现该程序写入stderr而不是stdout。在Web和堆栈溢出中搜索显示这是一个众所周知的事实。
Any idea why is this so?
知道为什么会这样吗?
1 个解决方案
#1
17
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 where mixed up.
在stderr上报告消息很常见,因为消息与stdout上的常规输出分开。将多个工具与管道组合时,这非常有用。在这种情况下,当常规输出和诊断消息混淆时,它会很糟糕。
#1
17
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 where mixed up.
在stderr上报告消息很常见,因为消息与stdout上的常规输出分开。将多个工具与管道组合时,这非常有用。在这种情况下,当常规输出和诊断消息混淆时,它会很糟糕。