Skip to content

Instantly share code, notes, and snippets.

@motleytech
Created April 13, 2016 23:37
Show Gist options
  • Save motleytech/4f3b3e4e09b7b6248c7e7c1eef64e28f to your computer and use it in GitHub Desktop.
Save motleytech/4f3b3e4e09b7b6248c7e7c1eef64e28f to your computer and use it in GitHub Desktop.
Python snippet to run external command and get output
import subprocess
def runCommandAndGetOuput(command):
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
(stdoutdata, stderrdata) = proc.communicate()
return stdoutdata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment