Python - store output of subprocess() call in a string
- by Mark
Hey all,
I'm trying to make a system call in Python and store the output to a string that I can manipulate in the Python program.
#!/usr/bin/python
import subprocess
p = subprocess.Popen("pwd")
# edit - actual command I want to store output of
p2 = subprocess.Popen("ntpq -p")
I've tried a few things including some of the suggestions here:
http://stackoverflow.com/questions/1996518/retrieving-the-output-of-subprocess-call
but without any luck.
Many thanks!