not working Re: help!! getting output from another process line by line, using popen

cout cout at netvigator.com
Fri Jan 17 05:44:24 EST 2003


P at draigBrady.com wrote:
> cout wrote:
> 
>> Help!!
>>
>> There are 2 python scripts, one is to print out the output(output.py),
>> the other is supposed to get std output from output.py line by line.
>> However, it only get all the result after 40 seconds. Not during the
>> executing process. Any ideas?
>>
>> ===========output.py==============
>> #! /usr/bin/python
>>
>> import time
>>
>> for i in range(1,20,1):
>>         print i
> 
>           sys.stdout.flush()
> 
>>         time.sleep(2)
>>
>> ================monitor.py===============
>> #! /usr/bin/python
>>
>> import os
>> import sys, string
>> cmd="python output.py"
>>
>> handle = os.popen(cmd, 'r', 1)
>> for line in handle:
>>     print line,
>> handle.close()
>>
> 
Thanks, but it doesn't work.
I run with script, it is same as before.

output.py is just a long process dummy program for simulation purpose.
We are not supposed to change it.






More information about the Python-list mailing list