Talking through pipes interactively (on win32)

Thorsten Pferdekämper thorsten at pferdekaemper.com
Mon Nov 10 11:11:48 CET 2003


"Jane Austine" <janeaustine50 at hotmail.com> wrote in message
news:ba1e306f.0311091118.24d80000 at posting.google.com...
> I need to control a command line program via python.
>
> I first tried popen2 and 3 but I couldn't find a way to talk to the
> subprocess interactively; that is, read some and then write some, and
> read some more again... (suppose controlling an interactive shell
> program) When I try this with popen family, it just hangs. I have to
> close one pipe before reading from the other.
>
> I know that there is a wonderful thing called Expect, but it's not
> available on my machine(win32).
>
> Can anyone help me out?

Hi,
in "Python in a nutshell", I have found a remark about that. It seems that
this depends on some buffering mechanisms the programs use. The program you
are running with popen just waits until the input stream is closed. As long
as you can not control the behaviour of this program, you hardly can do
anything, espacially on win32.
Perhaps you can try spawn().
Kind Regards,
    Thorsten






More information about the Python-list mailing list