【发布时间】:2015-05-08 11:14:25
【问题描述】:
我正在尝试通过 ActiveState TCL 'tclsh' 窗口中的 .tcl 脚本进行 ssh。 拥有WINDOWS OS系统。
#!/bin/sh
# \
exec tclsh "$0" ${1+"$@"}
package require Expect
set user [lindex $argv 0]
set password [lindex $argv 1]
set DeviceIpAddr [lindex $argv 2]
set DeviceHostName [lindex $argv 3]
foreach DeviceIp $DeviceIpAddr HostName $DeviceHostName {
spawn ssh $DeviceIp
expect "login as:"
send "$user\r"
expect "Password:"
send "$password\r"
expect "$HostName ~]#"
}
我在 tclsh(ActiveTCL) 中执行时看到以下错误
% tclsh Test.tcl root 321 17.250.217.151 lb02va
The system cannot find the file specified.
while executing
"spawn ssh root@$DeviceIp"
("foreach" body line 3)
invoked from within
"foreach DeviceIp $DeviceIpAddr HostName $DeviceHostName {
spawn ssh root@$DeviceIp
expect "login as:"
send "$user\r"
expect "Password:"
send..."
(file "Test.tcl" line 12)
child process exited abnormally
请帮助我解决这个问题。 谢谢。
【问题讨论】:
-
这是什么操作系统?
ssh程序安装在哪里?你的命令路径是什么?换句话说,PATH 环境变量的值是多少?请编辑您的问题以包含此信息。 -
我会说错误消息提示
spawnfailed to spawnssh因为操作系统无法在当前用户的PATH环境变量中列出的目录中找到名为“ssh”的程序——正如@Kenster 所说。因此,首先要尝试的是在运行tclsh二进制文件的同时运行ssh——它不起作用,问题与Tcl 无关,但与你的操作系统的基本知识有关. -
我是新手。如何查找/设置 PATH 环境变量的值?我正在尝试从 WINDOWS OS 系统运行。