I am currently executing a Bash command (via Python subprocess.Popen) that reads from stdin, does something and outputs to stdout. Sort of:
pid = subprocess.Popen( ["-c", "cmd1 | cmd2"],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
shell =True )
output_data = pid.communicate( "input data\n" )
Now I want to change this to execute another command in the same subshell, which will change state before executing the following commands, so my shell command line will now (conceptually) be:
cmd0; cmd1 | cmd2
Is there a way for an input to be sent in cmd1instead of cmd0in this scenario? I assume that the output will include the output cmd0(which will be empty), followed by the output cmd2.
cmd0doesn't really read anything out stdin, does it really matter in this situation?
, , , , cmd0, . , , .