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'命令。 –