Created
October 13, 2015 11:41
-
-
Save javierarilos/05ef20d9fb266d241521 to your computer and use it in GitHub Desktop.
Execute a Bash command in python, getting back return code, stdin and stdout.
This file contains hidden or 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 | |
p = subprocess.Popen(['ls', '-la'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
o, e = p.communicate() | |
print "Executed command ls -la with returncode", p.returncode | |
print " stdout ", o | |
print " error ", e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment