Created
October 25, 2012 12:16
-
-
Save adamatan/3952258 to your computer and use it in GitHub Desktop.
Python subprocess call
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/python | |
import subprocess as sp | |
# Pipes used to prevent buffer problems with verbose output. | |
# stdout is redirected to stderr. | |
# shell=True allows spaces in 'cmd'. | |
# communicate() waits for termination and empties buffers into 'output'. | |
cmd = "ls" | |
p = sp.Popen(cmd, shell=True, stdout=sp.PIPE, stderr=sp.STDOUT) | |
output = p.communicate()[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment