Friday, 23 August 2013

I want to get both stdout and stderr from subprocess

I want to get both stdout and stderr from subprocess

I just want to do something like this:
>>bar, err_value = subprocess.check_output("cat foo.txt", shell=True)
>>print bar
>>Hello, world.
>>print err_value
>>0
But I can't seem to be able to do it. I can either get the stdout, the
error code (via .call) or maybe both but needing to use some kind of pipe.
What am I missing here? The documentation is very sparse about this (to
me) obvious functionality. Sorry if this is a simplistic question.

No comments:

Post a Comment