Created
February 14, 2012 22:53
-
-
Save cemremengu/1831364 to your computer and use it in GitHub Desktop.
Again a stack overflow answer for reading the stdout of a subprocess 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
import subprocess | |
p = subprocess.Popen(["ntpq", "-p"], stdout=subprocess.PIPE) # ["command", "arg1", "arg2", "so on"] | |
out, err = p.communicate() | |
#you can then use out.split("\n") to get outputs as a list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment