TCL\Expect:: Script that is running on Windows XP is not running on Windows 7. Any ideas please?

北城以北 提交于 2019-12-11 04:48:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/25053164/tcl-expect-script-that-is-running-on-windows-xp-is-not-running-on-windows-7-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!