當我嘗試在Windows(expect543.dll
)上使用C實現期望解釋器來運行我的期望腳本時,出現錯誤「can't set "::exp::winnt_debug": parent namespace doesn't exist
」。 但是,如果我運行它通過ActiveState的命令tclsh的同一腳本正常工作......exp :: winnt_debug父命名空間錯誤
腳本語句「set ::exp::winnt_debug 1
」是錯誤的原因。 任何想法可能是什麼原因以及如何解決它?
請看以下代碼
package require Expect
set ::exp::winnt_debug 1
set prompt "R4#"
set more " --More--"
expect -timeout 10 "$prompt"
set output [open result.txt "w"]
set running 1
spawn plink -telnet "144.21.12.45" -P 2004
send "enable\r"
send "\r"
send "show running-config\r"
send "\r"
while { $running > 0 } {
expect {
"\n" { puts -nonewline $output "$expect_out(buffer)" }
"$more" {send " "}
"lines *-* " { send " " }
#"$prompt" { set running 0 }
eof { set running 0 }
timeout { set running 0 }
}
}
puts "output is .."
你如何激活Expect代碼? '包要求'? 'load'? –
我使用命令「package require expect」激活了它。已添加代碼供您參考。 –