我的TCL文件中有這樣的代碼下面,
proc executeCmd {cmd {file ""}} {
set out ""
set output ""
set send_slow {20 0.1}
set adminFlag 0
exp_send -s "$cmd\r"
for {set i1 0} {$i1 < 12} {incr i} {
set intimeout 0
expect {
# other options to check 'hostname', 'more', 'press any to continue' regexes
# ...
-regexp {^(.*)Press any key to continue.*$} {
set output [cleanOutput $expect_out(buffer)]
if {[regexp -- {\w+} $file]} {
append out $output
flush $fo
flush $clf
} else {
append out $output
}
exp_sleep 0.1
exp_send -s " "
exp_continue
}
timeout {
#log_msg INFO "TIMED OUT...."
puts "TIMED OUT"
set intimeout 1
puts "Executing $cmd >>> waiting for response from $hostname"
}
}
if {$intimeout} {
exp_send -s " "
} else {
break
}
}
return $out
}
spawn $plinkLoc -telnet $routerIP -P $routerPort
set out [executeCmd "term width 0"]
通過命令執行這個TCL之後提示我面對錯誤的說法,
send: spawn id exp4 not open
while executing
"exp_send -s "$cmd\r""
(procedure "executeCmd" line 28)
invoked from within
"executeCmd "term width 0""
invoked from within
"set out [executeCmd "term width 0"]""
這在TCL行代碼28「設置」聲明這是之前「executeCmd」 PROC,已經更新了查詢目的的文件。
你生成一個腳本?什麼是'$ plinkLoc'? – Dinesh
$ plinkLoc是plink.exe的路徑,m試圖通過產卵連接到路由器。 –
相同的腳本之前工作完全正常,在我的窗口更新時,我不確定它是因爲那個問題還是任何TCL補丁過期。即使經過如此多的挖掘,也無法追蹤它... –