Skip to content

Instantly share code, notes, and snippets.

@joedougherty
Created June 16, 2014 17:29
Show Gist options
  • Save joedougherty/5bf35c649738b2a7b95e to your computer and use it in GitHub Desktop.
Save joedougherty/5bf35c649738b2a7b95e to your computer and use it in GitHub Desktop.
Capture stdout, stderr, and return code from subprocess.Popen
from subprocess import Popen, PIPE
r = Popen(['/path/to/test.sh'], stdout=PIPE, stderr=PIPE)
stdout, stderr = r.communicate()
result = r.wait()
print(stdout, stderr, result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment