[Python-Dev] Expect in python

Eric S. Raymond esr@thyrsus.com
Fri, 22 Nov 2002 03:22:16 -0500


Martin v. Loewis <martin@v.loewis.de>:
> > I'm thinking this is a very strong candidate to enter the Python
> > library when it reaches 1.0 level.  Comments?
> 
> For that, we need a commitment of somebody to maintain it for us,
> preferably from the author of the package.

I've exchanged email with him.  I asked if he were aiming the package 
at the standard library.  He indicated that the thought had occurred
to him, but that he had no idea how to go about accomplishing that.
His phrasing was such that I'm pretty sure he was thinking "Yeah! Cool!" :-)

I told him that we don't have a formal process, but attracting the 
attention of someone on python-dev is usually where it starts.

The rest of the conversation was about some minor problems with the
module -- actually with ptys.  Seems the Solaris pty implementation 
is prone to hangs and fd leakage.  I got the impression that the guy
is pretty dedicated to the code and more than willing to maintain 
it for the long haul.

I can also report that I have finished about 3/4ths of the application
I was working on and can evaluate pexpect in more detail now.  

The application is an ssh key installer for dummies; you give it a
remote hostname and (optionally) the username to log in as. First, it
It walks the user through generating and populating a local .ssh with
keypairs if they're not already presennt.  It then handles all the
fiddly bits of making sure there's a remote .ssh directory, checking
permissions, copying public keys from the local .ssh to the remote
one, etc.

The idea is to allow a novice user to type

	ssh-installkeys remotehost@somewhere.com

and have the Right Thing happen.  This is worth automating because 
there are a bunch of obscure bugs you can run into if you get it
even slightly wrong.  ssh -d diagnostics deliberately don't pass back
warnings about bad file and directory permissions, for example, because
that might leak sesnsitive information about the remote system.  I plan
to give this script to the openssh guys for their distribution.

No surprise that I'm using pexpect to execute the remote commands. 
I can report that the interface seems pretty natural, I haven't run into
any sharp edges yet, and it does the job.  Anybody who has ever written 
an expect script will be productive with this puppy in 10 minutes flat.
-- 
		<a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a>