0
使用期望腳本重置服務器數據庫中的密碼時,出現以下消息。當我嘗試重置包含「!」的密碼時,我只出現此錯誤。作爲第一個字符。Expect腳本:傳遞參數時出現「event not found」
[[email protected]]# ./changepw username !password!
-bash: !password!: event not found
我的腳本如下:
#!/usr/bin/expect -f
## Set up variables to be passed in as command line arguments
lassign $argv username password
spawn telnet 127.0.0.1 23
expect "200 PWD Server ready"
send "USER admin\r"
expect "300 please send the PASS"
send "PASS password\r"
expect "200 login OK, proceed"
# Use the line below for a password that must be quoted ie one that contains a $ or a ! by escaping the double quotes
send "SETACCOUNTPASSWORD $username PASSWORD \"$password\"\r"
expect "200 OK"
send "quit\r"
interact
這似乎當我這樣做外的腳本的手動CLI同時放入引號內的密碼工作。它只與腳本失敗。
與您的腳本無關。事件未發現錯誤發生在你期望的腳本開始之前 - 在此之前,shell甚至檢查是否存在'changepw'命令。 –