This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Problems with cygwin, "expect" and ssh
- From: "Stepp, Charles" <Charles dot Stepp at T-Mobile dot com>
- To: <cygwin at cygwin dot com>
- Date: Wed, 24 May 2006 09:31:15 -0700
- Subject: Problems with cygwin, "expect" and ssh
I have found some interesting behavior regarding the cygwin expect/ssh
problem. I used the little expect script
That Corinna created. It seemed to not see the prompt for the password
from the spawned ssh, so it just timed out. But, when I redirect the
stderr to /dev/null, it behaves correctly. Perhaps ssh is spitting some
spurious bytes to stderr that are causing the expect pattern to not
match:
------------------------------------------------------------------------
GOOD:
cstepp@FLTAMLP0192593 ~
$ ./sshtest 2>/dev/null
spawn ssh -t 10.65.16.41
Before expect for assword:
cstepp@10.65.16.41's password: Found assword:
Before send of password
After send of password
Last login: Thu Jan 01 1970 00:00:00 from
[======================================================================]
Use of this system is explicitly limited to employees...
------------------------------------------------------------------------
-----
BAD:
cstepp@abcdefghi ~
$ ./sshtest
spawn ssh -t <hostname>
Before expect for assword:
cstepp@10.65.16.41's password: Spawning failed
cstepp@abcdefghi ~
------------------------------------------------------------------------
-------
SCRIPT:
cat sshtest
#!/usr/bin/expect -f
set timeout 10
spawn ssh -t <hostname>
puts "Before expect for assword:"
expect {
"*assword:" {
puts "Found assword:"
sleep 2
}
default {
send_user "Spawning failed\n"
exit
}
}
puts "Before send of password"
send "xxxxxxx\r"
puts "After send of password"
expect {
-re ".*\\$.* " { }
default {
send_user "Sending password failed\n"
exit
}
}
send "ls\n"
expect {
-re ".*\\$.* " { }
default {
send_user "Sending ls failed\n"
exit
}
}
send "exit\n"
expect {
-re ".*Connection to mycygwinbox closed.*" { }
default {
send_user "Sending exit failed\n"
exit
}
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/