Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expect and SSH in Cygwin

Status
Not open for further replies.

mryge

Programmer
Aug 21, 2004
1
US
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
 
Can't tell if you did so ...but does the -d option itself needs a debug-value (i.e. 0 - 9) or a keyword?

I've never used the debug option in Expect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top