Aziel
Aziel

Reputation: 331

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

Upvotes: 0

Views: 904

Answers (2)

anishsane
anishsane

Reputation: 20970

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

Upvotes: 1

Oleg Svechkarenko
Oleg Svechkarenko

Reputation: 2516

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

Upvotes: 0

Related Questions