Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 861
Adam Matan Avatar asked Aug 11 '09 07:08

Adam Matan


1 Answers

You can do this with subprocess.PIPE.

You can find some sample code here.

like image 191
Dave Webb Avatar answered Oct 20 '22 05:10

Dave Webb