title: SSH from pexpect (pxssh) fails when I try from a linux machine to a windows ssh client server
body: <p>I'm trying to run a python script which ssh from a linux machine to a windows server and runs a batch file.</p>
  
  <p>After some research, I realized that a pxssh class from pexpect is a ood module to use. When I try this module on linux to ssh to linux machine there is no problem. When I do it from a linux to windows it fails with the following error :
  pxssh failed on login.</p>
  
  <pre><code>pxssh failed on login.
  could not set shell prompt (received: ": \r\n\x1b[2J\x1b[1HMicrosoft Windows [Version 10.0.14393]\r\n(c) 2016 Microsoft Corporation. All rights reserved.\r\n\r\nC:\\Users\\myname&gt;unset PROMPT_COMMAND\nPS1='[PEXPECT]\\$ '\nset prompt='[PEXPECT]\\$ '\n", expected: '\\[PEXPECT\\][\\$\\#] ').
  </code></pre>
  
  <p>I remember from before windows had different way of ending lines and such (carriage return etc) from linux. I would like to know if anyway knows a solution to this problem.
  Please note that I'm manually able to use a shell from linux machine and ssh to a windows machine, it only fails when I try to write a python script and use pxssh.
  Thank you for your help.
  Please note that my next step would be to run a batch file and close the connection.
  My simple script:</p>
  
  <pre><code>from pexpect import pxssh
  import getpass
  try:                                                            
      s = pxssh.pxssh()
      #hostname = raw_input('hostname: ')
      #username = raw_input('username: ')
      #password = getpass.getpass('password: ')
      s.login ('192.168.0.144', 'username', 'password',  auto_prompt_reset=True)
      s.sendline ('dir')
      s.prompt()             # match the prompt
      s.sendline ('exit')
      s.logout()
      print "I'm here"
  except pxssh.ExceptionPxssh, e:
      print "pxssh failed on login."
      print str(e)
  </code></pre>
  
  <p>I use exit instead of logout because I think ssh client server on windows doesn't support logout</p>
  
  <p>Edit: I have disabled the auto_prompt_reset now I got the following:</p>
  
  <pre><code>Traceback (most recent call last):
    File "sshLogin.py", line 22, in &lt;module&gt;
      s.logout()
    File "/usr/local/lib/python2.7/dist-packages/pexpect/pxssh.py", line 355, in logout
      index = self.expect([EOF, "(?i)there are stopped jobs"])
    File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 321, in expect
      timeout, searchwindowsize, async)
    File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 345, in expect_list
      return exp.expect_loop(timeout)
    File "/usr/local/lib/python2.7/dist-packages/pexpect/expect.py", line 107, in expect_loop
      return self.timeout(e)
    File "/usr/local/lib/python2.7/dist-packages/pexpect/expect.py", line 70, in timeout
      raise TIMEOUT(msg)
  pexpect.exceptions.TIMEOUT: Timeout exceeded.
  &lt;pexpect.pxssh.pxssh object at 0xb72491cc&gt;
  command: /usr/bin/ssh
  args: ['/usr/bin/ssh', 'username@192.168.0.144']
  buffer (last 100 chars): 'Version 10.0.14393]\r\n(c) 2016 Microsoft Corporation. All rights reserved.\r\n\r\nC:\\Users\\myname&gt;exit\n'
  before (last 100 chars): 'Version 10.0.14393]\r\n(c) 2016 Microsoft Corporation. All rights reserved.\r\n\r\nC:\\Users\\myname&gt;exit\n'
  after: &lt;class 'pexpect.exceptions.TIMEOUT'&gt;
  match: None
  match_index: None
  exitstatus: None
  flag_eof: False
  pid: 4523
  child_fd: 5
  closed: False
  timeout: 30
  delimiter: &lt;class 'pexpect.exceptions.EOF'&gt;
  logfile: None
  logfile_read: None
  logfile_send: None
  maxread: 2000
  ignorecase: False
  searchwindowsize: None
  delaybeforesend: 0.05
  delayafterclose: 0.1
  delayafterterminate: 0.1
  searcher: searcher_re:
      0: EOF
      1: re.compile("(?i)there are stopped jobs")
  </code></pre>
  
  <p>Some resource which might be useful:
  <a href="http://pexpect.readthedocs.io/en/stable/overview.html" rel="nofollow noreferrer">http://pexpect.readthedocs.io/en/stable/overview.html</a></p>