Is it possible to catch data streams other than stdin, stdout and stderr in a Popen call?
<p>I am working on incorporating a program (samtools) into a pipeline. FYI samtools is a program used to manipulate DNA sequence alignments that are in a SAM format. It takes input and generates an output file via stdin and stdout, so it is quite easily controlled via pythons subprocess.Popen().</p>

<p>When it runs, it also outputs short messages to the console - not using stdout, obviously - and I wonder if it would be possible to catch these as well - potentially by getting a os generated handler list? </p>

<p>I guess my question in general is if it is possible to catch a programs console output if it is not coming from stdout? Thank you.</p>

<p>There is no other console output than stdout and stderr (assuming that samtools does not write to the terminal directly via a tty device). So, if the output is not captured with the subprocesses stdout, it must have been written to stderr, which can be captured as well using <code>Popen()</code> with <code>stderr=subprocess.PIPE</code> and inspecting the <code>stderr</code> attribute of the resulting process object.</p>

python stream subprocess stdout stderr