Python Forum

Full Version: a script i might need to write
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
a script i might need to write is to run another command is to capture both the stdout and stderr streams from that command, separately, with the order and interleaving preserved. so if that command writes to stderr first then to stdout, my script will see exactly what that command did. a test script would just copy the input to the output, so the command's stderr output goes to stderr, and the command's stdout goes to stdout.

does this sound too complicated?
Logging module? It's perfect to get both stdout and stderr.
logging module to do the parallel reading from two pipes or just as sample code?
For capturing both - stdout and stderr. It gives you more control and additional information what is going on.