开发者

Windows/WinXP CMD: How to pipe the output of a script to a log file AND display output?

I'm running python scripts from cmd. I am currently piping the output of the script to a log file that I specify. However, I would also like to be ab开发者_运维知识库le to visually monitor the progress of the execution by watching output scroll.

I'm piping to a log file because the window buffer is not sufficiently long to contain the entire log. However, the only way to get instant feedback of the current state of the execution is to keep refreshing the log file by opening it.

Can you suggest a better way to solve my problem? Ideally I'd like to pipe output to a file and display in cmd while it executes.

Thanks!


Use tee command from cygwin...

Or it is very easy to implement (at least basic version) of tee command yourself.

tee usage:
your_command | tee outfile.txt #overwrites file
your_command | tee -a outfile.txt #overwrites file

To capture stderr as well as stdout, use
your_command 2>&1 | tee [-a] outfile.txt


I would suggest some file viewer with autorefreshing option. Have a look at this questions from superuser.com:
Text / log editor with auto-refresh support
Log viewer on Windows

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜