simple popen question
Jim Benson
jbenson at sextans.lowell.edu
Fri Apr 2 17:48:01 EST 2004
Hi,
I use popen to run a binary executable.
A code snippit is below.
This part runs fine. I use readline()
to catch and print output from the binary
to the screen. The system obviously buffers
things. i.e. readline doesn't return after every
line of output from the executable.
Is there an easy way to turn off the buffering?
I tried adding the extra 'r' and a small bufsize
to the popen...no difference.
iFd = os.popen(self.sCmd + ' ' + sArgs)
# Run sCmd
while True:
line = iFd.readline()
if line == '':
# EOF found...break out.
break;
print '%s' % line[:-1]
iRet = iFd.close()
if (iRet != None):
print 'ERROR: error message'
Thanks,
Jim
More information about the Python-list
mailing list