Python Subprocess – Redirect stdout/err to two places


I have a small python script which invokes an external process using subprocess. I want to redirect stdout and stderr to both a log file and to the terminal.

How can this be done?

Best Solution

You can do this with subprocess.PIPE.

You can find some sample code here.