STDERR? What is it? What are its common uses?

六月ゝ 毕业季﹏ 提交于 2019-12-18 17:29:12

问题


Curious about how the handle STDERR works? Lets keep it down to say Batch Files to keep it simple and focused? I know that many programming languages accept STDERR, so I don't know if maybe uses are different across the board or maybe there is a common function for all programming languages?

If anyone can provide some examples on common usage that you have seen or an explanation of why someone may utilize it for ??? situation that would be awesome.

Thanks in advance!


回答1:


Usually you would use stderr for error messages.

If you run a program on the command line, you can capture its stdout and/or stderr

For example:

myprogram.exe > stdout.txt

will capture anything written by myprogram.exe to stdout and place it in stdout.txt. However, stuff written to stderr will not be put into stdout.txt. Thus you can capture the program's regular output without capturing error messages.




回答2:


STDERR stands for Standard Error. It, as the name suggests, primarily used for reporting erroneous behavior. By default, on every system I know of, I points to the terminal just like STDOUT. These entities are represented separately, however, allowing the user to print only normal output to the terminal and redirect errors to a log (just one example).



来源:https://stackoverflow.com/questions/6364180/stderr-what-is-it-what-are-its-common-uses

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!