Problems controlling another program

John Roth johnroth at ameritech.net
Mon Aug 20 01:54:10 EDT 2001


"Sven Herzberg" <herzi at runbox.com> wrote in message
news:9ljv28$6ne$02$1 at news.t-online.com...
> Hi,
>
> I'm trying to create a front-end for a linux console application. My
> problem is that the command line tool has to run the whole time while the
> GUI is running. The GUI and the command line tool shall permanently
> exchange data with each other. I tried with popen2 and I didn't succeed.
> If you can help me, send me some info, please.
>
> Thanks
>
> --
> sven

The standard answer for this one is: use Expect. Of course, you will need
to learn TCL/TK for that package, but it works. There's also an Expect
module in Perl, but I don't know of one in Python.

The reason you need something like Expect is that you need a pty rather than
pipes in the general case, because most Unix command line programs really
do expect that they are running with a real user if they are doing any kind
of
conversation. They get totally baffled between the C standard library on the
interactions. The standard library is smart enough to not buffer ttys but it
usually isn't smart enough to not buffer pipes.

Look at the tty module in the stand library. It's very minimal, but you
might
be able to get it to work for you, since it claims to run on Linux.

John





More information about the Python-list mailing list