Following is my TCL/Expect Script:
package require Expect
spawn telnet 2.2.2.10
expect "*ogin:"
send "admin\r"
expect "*word:"
send "test\r"
expect "*>"
send "enable\r"
expect "*#"
The above script runs in "Windows XP" machine. But when I run this same script in "Windows 7", its throws following error:
C:\Users\test\Desktop>tclsh 3_AP_collect_sign.tcl
The system cannot find the file specified.
while executing
"spawn telnet 2.2.2.10"
(file "3_AP_collect_sign.tcl" line 6)
C:\Users\Symbol\Desktop>
Please help me to run this script in "Windows 7" machine. Should I add anything to run in Windows 7?. Thanks in Advance.
Thanks,
Balu P.
The problem is that there is no telnet.exe
on your PATH
in Windows 7. You may find that plink.exe
from the PuTTY suite (with suitable options) is an acceptable replacement, but there are probably others too.
It's also possible that telnet.exe
exists but is marked (by the system) as impossible to attach a debugger to (which is how Expect really works under the covers on Windows; this is very deep hackery and I'm not the inventor of it!) Even if that's the case, the fix is the same: find an alternative program.
It's also possible to emulate telnet entirely in Tcl code, but a lot of work as Telnet is a pretty messy protocol and terminal emulation is grindingly annoying. Not a recommended approach.