J
Jim Benson
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
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