Last active
August 29, 2015 14:06
-
-
Save algas/c332790830967090c476 to your computer and use it in GitHub Desktop.
Python Subprocess Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import collections | |
CommandResponse = collections.namedtuple('CommandResponse', ['code', 'out', 'err']) | |
def run_command(cmd): | |
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
sout, serr = p.communicate() | |
return CommandResponse(p.returncode, sout, serr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment