Using pxssh

Nick Craig-Wood nick at craig-wood.com
Mon Mar 19 20:30:07 CET 2007


tereglow <tom.rectenwald at eglow.net> wrote:
>  I am trying to convert some Expect/Tcl code into Python by using the
>  Pexpect module.  The environment is such that authenticated keys are
>  disabled although SSH is available.  I do not have control over this
>  environment, so I'm trying to automate tasks within it via Expect.
> 
>  I noticed that, within the Pexpect documentation, it mentions a class
>  called "pxssh".  Has anyone used this before?  If so, I'm having some
>  trouble importing it.  If I just import pxssh doesn't seem to work;

In what way doesn't it work?

>  really am not sure how this is related to Pexpect or how to use it
>  from within it.

It works for me according to the documentation

  $ python
  Python 2.4.4 (#2, Jan 13 2007, 17:50:26) 
  [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import pxssh
  >>> s = pxssh.pxssh()
  >>> s.login("localhost", "user", "password")
  True
  >>> s.sendline("ls -l")
  6
  >>> s.prompt()
  True
  >>> print s.before
  ls -l
  total 30944
  -rw-r--r--   1 user  user       936 Nov  3 14:52 #z.c#
  [snip]
  -rw-r--r--   1 user  user       221 Jan 30 11:51 z~
  >>> s.logout()
  >>> 

I'm using the debian packaged version 2.1-1 with python 2.4

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list