shell command output

Sorin Gherman s_gherman at yahoo.com
Mon May 21 01:06:58 EDT 2001


Hi,
I need to get the output of a shell command in bash, under win32.
Something similar to the bash script:

DIFF_RESUlT=`diff f1 f2`
echo $DIFF_RESULT

The only solution I can think of is to use a temp file:

os.system("diff f1 f2 > tmp")
tmpfile = open("tmp")
tmpcontent = tmpfile.readlines()
for line in tmpcontent:
   print line

Is there any solution to avoid the temp file?

Thanks in advance,
Sorin Gherman



More information about the Python-list mailing list