Skip to content

Instantly share code, notes, and snippets.

@adamv
Created November 12, 2010 16:24
Show Gist options
  • Select an option

  • Save adamv/674295 to your computer and use it in GitHub Desktop.

Select an option

Save adamv/674295 to your computer and use it in GitHub Desktop.
Cheesy "run command and give me status, stdout, stderr" Python function
from subprocess import Popen, PIPE
def local2(command, print_command=False):
"Run a command, returning the exit code, output, and stderr."
p = Popen(command, stdout=PIPE, stderr=PIPE)
if print_command: print " ".join(command)
output, errput = p.communicate()
return p.returncode, output, errput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment