it does not work again. Re: help!! getting output from another process line by line, using popen
printf at hongkong.com
Fri Jan 17 15:11:20 CET 2003
Lao Coon wrote:
> cout <cout at netvigator.com> wrote in news:b08ka1$q8l8 at imsp212.netvigator.com:
>>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?
>>for i in range(1,20,1):
>> print i
>>import sys, string
>>handle = os.popen(cmd, 'r', 1)
>>for line in handle:
>> print line,
> This has something to do with the way the output is returned here..
> When you say "for line in handle" read() is called, it waits
> until everything has been received and then returns it as a list(only once).
> To fix it explicitly call readline() instead.
if you mean that "handle = os.popen(cmd, 'r', 1).readlines()", it wont
work. it waits till finish running cmd, then go to the "for loop".
More information about the Python-list