469,288 Members | 2,357 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,288 developers. It's quick & easy.

simple popen question


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


Jul 18 '05 #1
1 1252
In article <ma**************************************@python.o rg>,
Jim Benson <jb*****@sextans.lowell.edu> wrote:

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'

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Sean Berry | last post: by
2 posts views Thread by Stuart McGraw | last post: by
6 posts views Thread by Robin Siebler | last post: by
5 posts views Thread by damacy | last post: by
2 posts views Thread by hubritic | last post: by
2 posts views Thread by stephen_b | last post: by
3 posts views Thread by Jesse | last post: by
12 posts views Thread by Eric_Dexter | last post: by
15 posts views Thread by Daniel Klein | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.