I am getting the following message while using an expect script to reset a password in a server database. I only get this error when I try to reset a password that contains a "!" as the first character.
[root@server]# ./changepw username !password!
-bash: !password!: event not found
My script is as follows:
#!/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
This does seem to work when I do this manually outside of the script from CLI while enclosing the password in quotes. It only fails with the script.