0

Everytime I try to use winpexpect to spawn terminal (eg: openssh, ssh). if I do winpexpect.winspawn('ssh ...') I am met with "Pseudo-terminal will not be allocated because stdin is not a terminal.". If I force a terminal using winpexpect.winspawn('ssh -t -t ...') then I just get nothing in my read buffer, even though the ssh client REALLY is connecting to the server. The same goes with other interactive terminals, they just hang and nothing shows up in the read buffer. However for commands that terminal, such as ping winpexpect works.

What I have found that does actually work is using putty's plink.exe, winpexpect.winspawn('plink ...'. This is the same as putty.exe, but it doesn't do terminal emulation, I just get the raw telnet/decrypted ssh data. However this isn't really ideal solution.

I am really stuck at how to get get a spawner/expect library to work with terminals on windows! I have even tried using expectJ, just pure Java, and that too has the same issue.

Zombies
  • 25,039
  • 43
  • 140
  • 225
  • Have you thinked about using paramiko instead? – Paulo Scardine Sep 21 '12 at 00:34
  • It may have to do with pty's not being native to Windows. I'm not sure how they implement it, but most likely they have to simulate them in some way. The `os.openpty` function doesn't even exist on Windows. So I would expect it to be "dicy". Are you running this is cygwin? or using the native Python build? – Keith Sep 21 '12 at 01:05
  • paramiko... would require a lot of rewriting. I am trying to move something that is written using telnetlib, which has expect methods on it already. My goal is to use winpexpect to invoke an ssh client. This would be a very straightforward approach and require not rewriting. – Zombies Sep 21 '12 at 02:10
  • @Keith CPython, native windows. I suppose I would get what I am looking for if it were through cygwin. – Zombies Sep 21 '12 at 02:11

1 Answers1

0

What's wrong with winpexpect/plink? You can try the forked winpexpect which fixed many issues on the winpexpect-1.5

Jruv
  • 1,438
  • 2
  • 9
  • 10