15

This is the code I am trying to run:

from pexpect import pxssh
s = pxssh.pxssh()
if not s.login ('myip', 'myusername', 'mypassword'):
    print ("SSH session failed on login.")
    print (str(s))
else:
    print ("SSH session login successful")
    s.sendline ('ls -l')
    s.prompt()         # match the prompt
    print (s.before)     # print everything before the prompt.
    s.logout()

The error which I am getting on running this is :

Traceback (most recent call last):
  File "test_pexpect.py", line 1, in <module>
    from pexpect import pxssh
  File "C:\Python35\lib\site-packages\pexpect\pxssh.py", line 23, in <module>
    from pexpect import ExceptionPexpect, TIMEOUT, EOF, spawn
ImportError: cannot import name 'spawn'

Can anyone help me out? I am using python3.5 on windows

Oliver Blue
  • 677
  • 2
  • 9
  • 22
  • Tried this on a Windows machine myself and the `from pexpect import pxssh` is giving me the same issue. I cannot find an alternate way to use pxssh either, so either there's a bug in the current version on pip or there is another way to use this that I did not find in a quick skim of documentation on pexpect/pssh. I ran out of time to investigate further but wanted to share that I experience the same thing! – Anna Apr 26 '16 at 19:32
  • 1
    Apparently spawn is not supported yet on Windows. Its there in their documentation. Do you know of any better way to ssh in python through windows? I am trying to use paramiko put pycrypto is throwing me lot of errors. Thanks for your time, though. – Oliver Blue Apr 26 '16 at 19:35
  • I haven't used any myself but there's a few things to look at here: https://wiki.python.org/moin/SecureShell – Anna Apr 26 '16 at 20:51

1 Answers1

11

pxssh is not currently supported on Windows.

You can read more about it on https://github.com/pexpect/pexpect/issues/339

stefan.stt
  • 2,357
  • 5
  • 24
  • 47