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

匿名 (未验证) 提交于 2019-12-03 01:09:02

问题:

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 able 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!

回答1:

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



回答2:

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



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