Skip to content Skip to sidebar Skip to footer

No Output From Subprocess.check_output()

I'm trying to run the following code in Python 2.7.5: output = subprocess.check_output(commandList) print (len(output)) My command list is a list of arguments like: ['ls', '-l'].

Solution 1:

This is supposed to work, but it's possible that the actual command you're running (presumably not ls) is buggy and sending all of its output to stderr instead of stdout. Try

output = subprocess.check_output(commandList, stderr=subprocess.STDOUT)

Post a Comment for "No Output From Subprocess.check_output()"