I'm pretty new to Python and trying to find an approach for setting up several shell env variables and then executing a shell script.
Is the subprocess
module capable of sending several shell commands and capturing the output?
This isn't clear to me, since each spawn will result in a new shell thread that will not have the previous env variable.
Also, would it be appropriate to use popen
or check_output
?
Essentially what I'd like to do is:
$ setenv a b
$ setenv c d
$ setenv e f
$ check_status.sh > log.log
$ grep "pattern" log.log
Where check_status.sh
must have the above env variables defined to run properly, and it also must be shell script (i.e. I can't translate check_status.sh
to python).
I'd appreciate you comments and input.