popen in real time?

te at first.gmd.de te at first.gmd.de
Thu Jun 8 12:00:38 EDT 2000


In article <8hjdn4$6kf$1 at bmerhc5e.ca.nortel.com>,
  msoulier at nortelnetworks.com wrote:
>
> 	Hey guys. I realize that you can loop on the output of popen if you
want
> to read from a pipe, but it would seem from experience that the output
of the
> child process is not available until the process exits. I've tried
this with
> the output of long-running processes like find. Is there a way to get
the
> output of a child in real time, as it's printed?
>
> 	Mike
>

Somebody already pointed to (Tcl's) expect and the
(basic) Python pty stuff.

I found Paul Sheer's Python extension "expect"
(aka expectmodule) to be very helpful for such
tasks. It combines the use of ptys with an easy
to use interface that is largely an extension to
popen/2/3.

See ftp://ftp.obsidian.co.za/pub/expect/

I'm not sure, however, how platform-dependent
this extension is. I used it on Linux
(Debian 2.2).

BTW this is not the only Python-related "expect"
out there, but I used only this one, and
enjoyed it. Vaults of Parnassus has the
alternatives, too.

Regards,

Thilo


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list