我正在編寫一個期望腳本來自動執行Sophos安裝。這裏是什麼樣子:期望腳本不識別「--MORE--」,之後沒有運行任何命令
#!/usr/bin/expect
set installdir [lindex $argv 0]
set timeout 20
spawn "./install.sh"
expect {
sleep 5
"Press <return> to display Licence. Then press <spc> to scroll forward." {send "\r"}
-ex "--More--" {send -- " "; exp_continue}
"Do you accept the licence? Yes(Y)/No(N)\\\[N\\\]" {send "Y"}
"Where do you want to install Sophos Anti-Virus? \\\[/opt/sophos-av\\\]" {"send $installdir/sophos-av"}
"Do you want to enable on-access scanning? Yes(Y)/No(N) \\\[Y\\\]" {"send \r"}
"Do you want to enable remote management? Yes(Y)/No(N) \\\[Y\\\]" {"send \r"}
"Username for Sophos Anti-Virus GUI? \\\[admin\\\]" {"send \r"}
"Password for Sophos Anti-Virus GUI?" {"********"}
"Re-enter the same password." {"********"}
}
interact
當我運行expect腳本,它進入的許可證的按鍵,但什麼都不做,當第一「 - 更多 - 」提示出現,並運行沒有後續命令。思考?想法?
「睡眠5」不是睡眠命令:expect會尋找睡眠模式,如果發現執行命令「5」。如果你真的想睡覺,把命令放在expect命令的上面。 – 2015-04-06 13:21:30