Skip to content

Instantly share code, notes, and snippets.

@diegorocha
Last active August 29, 2015 14:21
Show Gist options
  • Save diegorocha/964e9f8b0a740611151c to your computer and use it in GitHub Desktop.
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
#!/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