Created
November 5, 2016 11:03
-
-
Save jovianlin/a9df23416f5e62d2a56e0f3eb5d21b9a to your computer and use it in GitHub Desktop.
Execute Linux Commands in Python
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
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