Simultaneous output parsing of child process?

Emile van Sebille emile at fenx.com
Thu Oct 2 12:05:01 EDT 2003


"Fraser Gordon" <fraser.gordon at cognos.com> wrote in message
news:deb65cae.0310020645.3af9cf62 at posting.google.com...
> Hello,
>
> Hopefully someone can help me out with this issue...
>
> I have a python script that needs to run a shell command and be able
> to react to output from that command as it occurs (as opposed to
> waiting for the whole command to complete and then parsing the
> output).  Is this possible with Python?
>
> I created a test script that prints a line of output to stdout every 4
> seconds or so.  I want to create a "parent" script that kicks off the
> test script, and prints data as soon as the test script sends anything
> to the standard output (ie. every 4 seconds).
>
> Furthermore, the solution needs to support Windows, several flavors of
> UNIX and potentially LINUX.
>


Perhaps something that Donn Cave posted a few years ago helps, particularly
the bonus version ;-):

http://groups.google.com/groups?selm=8vbqil%249er8%241%40nntp6.u.washington.edu

It doesn't work as is on windows, but I've used it as a base on linux
several times.

HTH,

--
Emile van Sebille
emile at fenx.com







More information about the Python-list mailing list