我有一個tcl(expect)腳本來登錄到設備和傳輸文件。不幸的是,這些文件很大,在傳輸期間ssh連接結束(文件仍然被傳輸)。所以我基本上必須再次登錄才能在設備上執行更多操作。由於整個登錄過程很長,我把它放在一個proc中。問題是proc登錄到設備中,但登錄後,腳本將命令發送到終端,因爲某些原因,命令不再到達設備。我不知道爲什麼我在proc中登錄的會話沒有傳遞給腳本的其餘部分。使用tcl proc登錄到設備
proc login {} {
#login code - it works because I took it from the main script (which works).
# variables are all declared as global, no errors are thrown. Login is successful
}
login
send "show\r" ;# this command is not sent to the device,
#instead it prints to the terminal. When in the main script,
#these commands would not be printed to the terminal window.
是否有一個命令我想失望,可能會返回登錄會話到腳本的其餘部分?類似於interact
命令的內容,但涉及腳本的其餘部分。
是的!這工作,非常感謝! – user2883071 2015-03-16 14:33:19