Skip to content

Instantly share code, notes, and snippets.

@cemremengu
Created February 14, 2012 22:53
Show Gist options
  • Save cemremengu/1831364 to your computer and use it in GitHub Desktop.
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
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