How do I get stdout directly into a Python variable
David Lees
debl2nonospammywham at bellatlantic.net
Mon Feb 25 19:44:38 EST 2002
I am playing with a Python script that issues system commands on linux
and I want the stdout to go directly into a Python variable. Right now
I am writing to a temp file and then opening it up. This seems like a
hack.
I am doing something like this:
os.system('diff file1 file2 | wc > temp')
fh = open('temp','r')
line = fh.read()
fh.close()
I see examples of redirecting stdout in texts, but this still creates a
file that needs to be opened.
Thanks in advance.
David Lees
More information about the Python-list
mailing list