Problems controlling another program

Wayne piercew at hushmail.com
Mon Aug 20 14:00:18 CEST 2001


"John Roth" <johnroth at ameritech.net> wrote in message news:<to19dvg0ci6pea at news.supernews.com>...
> "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

I haven't used this module, but here's the PyExpect homepage:

http://sourceforge.net/projects/expectpy/

Wayne



More information about the Python-list mailing list