Last active
August 29, 2015 14:21
-
-
Save diegorocha/964e9f8b0a740611151c to your computer and use it in GitHub Desktop.
Exemplo de utilização do Popen para chamar e interagir com outros programas
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
#!/usr/bin/env python | |
from subprocess import Popen, PIPE | |
cmd = 'uname -a' | |
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) | |
out, err = p.communicate() | |
code = p.returncode | |
print 'Status: %d\n%s\nErro:%s' % (code, out, err) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment