Skip to content

Instantly share code, notes, and snippets.

@jovianlin
Created November 5, 2016 11:03
Show Gist options
  • Save jovianlin/a9df23416f5e62d2a56e0f3eb5d21b9a to your computer and use it in GitHub Desktop.
Save jovianlin/a9df23416f5e62d2a56e0f3eb5d21b9a to your computer and use it in GitHub Desktop.
Execute Linux Commands in Python
from subprocess import Popen, PIPE, STDOUT
def run(cmd):
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
return p.stdout.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment