Scripting SSH with Python

Matthew Dixon Cowles matt at mondoinfo.com
Tue Oct 24 16:43:44 EDT 2000


On Tue, 24 Oct 2000 13:21:30 -0700, Lenny Self <lenny at squiggie.com>
wrote:

>I am scripting SSH or actually rsync using ssh and I am in need of a
>bit of help.  When I make the SSH connection I am prompted to enter a
>password...  my problem is that I don't know how to look for this
>promt and have the script submit the password for me.  Can anyone
>give me some help on this.

>I have been experimenting with os.popen and os.popen3 but I am either
>looking in the wrong spot or I am not doing it correctly.

Lenny,
You're on the right track but (as you've found) messing around with
getting the IO to be correctly unbuffered and searching for the right
strings quickly gets to be a nuisance. That's why there's Expect
(which uses Tcl) and the various Expect-like Python modules. If you go
to the Vaults of Parnassus:

http://www.vex.net/parnassus/

and do a search for "expect" I bet that you'll find something that
will make your life easier.

Regards,
Matt



More information about the Python-list mailing list