| |||||||||||
Expect and SSH in Cygwin Posted by mryge (mryge), 22 August 2004 Hi,I am trying to connect to a remote Windows Server 2003 machine via SSH from my local machine. The remote machine runs an OpenSSH server. I tried to connect with an OpenSSH client in Cygwin. From the (Cygwin) bash, I typed: $ ssh remote_machine -l Administrator Then, the bash would output: "Administrator@remote_machine's password: " This complete procedure worked fine. However, when I ran my Expect script, issh.tcl, to do the same thing, I got frustating *unexpected* behaviors. --- Expect script (start) --- #!/bin/sh # \ exec tclsh "$0" ${1+"$@"} package require Expect spawn ssh remote_machine -l Administrator expect "password: " send "my_password\r" expect "Administrator>" --- Expect script (end) --- When I ran the script with -d option: --- start --- expect version 5.26 argv[0] = expect argv[1] = -d argv[2] = issh.tcl set argc 0 set argv0 "issh.tcl" set argv "" executing commands from command file issh.tcl spawn ssh remote_machine -l Administrator parent: waiting for sync byte parent: telling child to go ahead parent: now unsynchronized from child spawn: returns {3420} expect: does "" (spawn_id 4) match glob pattern "password: "? no Administrator@remote_machine's password: --- end --- The strange thing is on the line: expect: does "" (spawn_id 4) match glob pattern "password: "? no. Why did I get ""? What character is that? If I connected directly (without using Expect), I never received the "". Any help is greatly appreciated. Memomana Posted by admin (Graham Ellis), 22 August 2004 The "" you talk about is nothing - so it's saying it got nothing. I think it probably times out. Is there a pause of about 10 seconds?Looking back at the other thread you've had running on the same subject, I'm still in some doubt as to whether the remote program (OpenSSH client you say) really is prompting for the password - I would expect your debug dump to say "got 'password' " but I didn't see that. To try this out, try adding local puts commands into your Expect script between every step ... and remember to flush stdout too; this will tell you where the problem is hanging up. Do you have access to a true Linux or Unix box running a recent version of Expect on which you can test your script? The current vesrion of Expect is 5.42 rather than 5.26, but that may be a red herring. Posted by Bazab (Bazab), 17 November 2004 I am having a very similar problem. I am using the latest version of Cygwin. I get the same mismatches when I try to send the password. I also tried autoexpect and what I noticed is that as soon as I try the first letter of the password I get invalid password immediately so I think expect has an issue with the way the password is echoed in cygwin. I tried a very simple ftp script on a linux system and it worked fine but I need it to work on my windows box through cygwin.Are there any terminal setting I could try or tricks within expect? I am also very new to this so be gentle. Thanks Posted by admin (Graham Ellis), 17 November 2004 If you're getting an immediate error, I wonder if you're sending too much too quickly, or sending a new lline after each character? Hand you tried pausing before you send, or send_slow or send_human? Have you tried the other "tricks" I suggested in my previous answer?I'm suspecting that ssh is intentionally sensitive to automaton talking thtough it, so you have to get it exactly right but in terms of character sequences (obvious) and human-like timing (not quite to obvious). Posted by Bazab (Bazab), 17 November 2004 I have tried a variety of those things. From looking at the debug info, it is happening after the first character of the password is sent. That leads me to believe that cygwin is transmiting each character of the password as it is entered since I also had the problem with autoexpect. Any other ideas? Oh, and I am not using ssh, this is happening while trying to do an ftp from cygwin on Win XP to an ftp server. It works fine from a linux box to the same server using expect.Posted by admin (Graham Ellis), 17 November 2004 Looks like a problem in autoexpect, I guess ...I wonder if you're looke at ActiveState's Expect for Windows - NOT a free product but if it's close to a "proper" expect it may sort the problem. I gues syou could email them to enquire - as they're selling the software they'll probebly want to answer you (and there may be a trial download - I'm not sure ...) This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |