C
Casey Bralla
I know this problem has a very simple answer, but I've checked the web and I
don't understand the answers that I've found.
How do I return text from a standard Linux command?
For example: I want to read the stdout results of a typical linux command
(such as "df") into a Python variable.
I've tried these techniques:
result = os.system("df")
It dumps the stdout to a screen and puts the result code into "result"
result = popen2("df")
It gives me a tuple of the stdin & stdout pipes, which I don't know how to
harvest into the actual stdout result.
Can someone give me a brief code example of how to get the actual text
result from the linux command into a Python variable? Thanks!
don't understand the answers that I've found.
How do I return text from a standard Linux command?
For example: I want to read the stdout results of a typical linux command
(such as "df") into a Python variable.
I've tried these techniques:
result = os.system("df")
It dumps the stdout to a screen and puts the result code into "result"
result = popen2("df")
It gives me a tuple of the stdin & stdout pipes, which I don't know how to
harvest into the actual stdout result.
Can someone give me a brief code example of how to get the actual text
result from the linux command into a Python variable? Thanks!