os.popen

Thomas Guettler guettli at thomas-guettler.de
Thu Feb 19 11:06:59 EST 2004


Am Thu, 19 Feb 2004 10:18:56 -0500 schrieb Bart Nessux:

> Thank you for that explanation. It makes sense. When you say loop the 
> read do you mean something like this:
> 
> ping = os.popen('sh ./ping.sh')
> while 1:
>     ping.read()
> ping.close()
> 
> I liked the /dev/null examples too as I don't need output from some of 
> the functions. I didn't know I could throw output away like that.

ping.read() will wait until EOF (End of File). You should
call it only once. This means ping.read() will return
as soon as the ping stopped pingging.

I think you can give the number of bytes to read
as an argument.

 thomas



More information about the Python-list mailing list