在标准的Windows .cmd文件中,我只需执行以下操作即可向stdout发送消息:
echo message
Run Code Online (Sandbox Code Playgroud)
如何向stderr发送消息?
示例:
假设我的脚本parent.cmd包含:
call child.cmd 1>>stdout.log 2>>stderr.log
Run Code Online (Sandbox Code Playgroud)
和一个孩子包含:
:: Writes a message to stdout
:: (which in the parent is piped to stdout.log)
echo message
:: Now I want to write a message to stderr
:: (which in the parent is piped to stderr.log)
???
Run Code Online (Sandbox Code Playgroud)
dol*_*phy 63
您可以尝试将STDOUT的句柄重定向到STDERR的句柄.在子进程中,使用句柄重定向执行回显:
:: Writes a message to stdout
:: (which in the parent is piped to stdout.log)
echo message
:: Now I want to write a message to stderr
:: (which in the parent is piped to stderr.log)
echo message 1>&2
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21688 次 |
| 最近记录: |