By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,201 Members | 922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,201 IT Pros & Developers. It's quick & easy.

simple popen question

P: n/a

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
Share this Question
Share on Google+
1 Reply


P: n/a
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.