is there a way to pipe STDERR and STDOUT to different programs?

╄→尐↘猪︶ㄣ 提交于 2020-01-16 19:01:09

问题


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 ?


回答1:


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 line show STDOUT output preceded by green numbers and STDERR output preceded by red ones. Just use your TEE program instead findstr...

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




回答2:


You can redirect stdout and stderr to different files but that's about as far as it goes.

If the make output can be time coded on every line then the two files could be adjusted and re-interleaved.



来源:https://stackoverflow.com/questions/16762674/is-there-a-way-to-pipe-stderr-and-stdout-to-different-programs

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