In Python I want to call a script that prints to the screen as it executes while also logging the stdout and stderr streams. I have the following line of bash code that I'd like to execute:
script.sh > >(tee /tmp/success.log) 2> >(tee /tmp/errors.log >&2)
where script.sh is any script that outputs to both stdout and stderr. This line captures the stdout and stderr streams into the log files success.log and errors.log and also outputs the streams to stdout, as explained here: How do I write stderr to a file while using "tee" with a pipe?
Now I want to execute this from within python using subprocess.call(that_command_as_str, shell=True), but python uses /bin/sh to execute the command instead of /bin/bash, and vanilla sh doesn't support that type of redirection. It seems the usage of /bin/sh is hardcoded into the subprocess module. Any Ideas?