Using Python to run SSH commands on a remote server

Grant Edwards grante at visi.com
Mon Jun 23 16:12:59 EDT 2008


On 2008-06-23, John Salerno <johnjsal at NOSPAMgmail.com> wrote:

> Generally speaking, what tools would I use to do this?

In shell scripts I use expect to automate ssh stuff, so I would
probably give pyexpect or pexpect a try:

  http://sourceforge.net/projects/pexpect/

> Is there a built-in module for it? I looked at the telnetlib
> module, but the documentation wasn't really complete enough
> for me to get a good idea of it. Is Telnet and SSH even the
> same thing?

Not even close.

> Basically, I want to write a script that will automate the
> process of making all .py files on my web server executable
> (chmod 755, or something similar).

I'd probably just write an expect script:

  http://expect.nist.gov/

-- 
Grant Edwards                   grante             Yow! Is a tattoo real, like
                                  at               a curb or a battleship?
                               visi.com            Or are we suffering in
                                                   Safeway?



More information about the Python-list mailing list