是有办法管STDERR和STDOUT不同的节目? [英] is there a way to pipe STDERR and STDOUT to different programs?

查看:156
本文介绍了是有办法管STDERR和STDOUT不同的节目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如我需要设置这样的方式二三通命令,一个从STDOUT STDERR从在阅读和第二无一不重定向控制台输出到不同的文件。这样的事情有可能在Windows批处理文件?我知道如何将输出重定向到文件,但在这种情况下,它不会对管道屏幕或如何既流结合起来,但如何同时显示独立?

For example I need to set two tee commands in such way that one will be reading from STDOUT and second from STDERR and both redirecting the console output to different files. Is such thing possible in windows batch files ? I know about how to redirect output to file but in this case it won't be displayed on screen or how to combine both streams but how about piping both independently ?

推荐答案

您可以处理输出和错误通过下一招单独的程序:

You may process STDOUT and STDERR with separate programs via the next trick:

(test | findstr /N /A:2A "^" ) 2>&1 1>&3 | findstr /N /A:4E "^"

previous秀行输出到标准输出$ P $绿色号码和红色的pceded STDERR输出preceded。只需使用您的TEE程序,而不是FINDSTR ...

Previous line show STDOUT output preceded by green numbers and STDERR output preceded by red ones. Just use your TEE program instead findstr...

如果你还没有为批处理文件足够的TEE程序,你可能会在这里找到一个:<一href=\"http://stackoverflow.com/questions/796476/displaying-windows-command-prompt-output-and-redirecting-it-to-a-file/16641964#16641964\">Displaying Windows命令提示符输出重定向到一个文件

If you have not an adequate TEE program for Batch files, you may find one here: Displaying Windows command prompt output and redirecting it to a file

这篇关于是有办法管STDERR和STDOUT不同的节目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆