I want to change the password on my server.
There are four possible passwords that should all be accepted for changing a password on the server.
To achieve this I want write an "expect" script which logs into my server and does something. But I don't know which password the device is using, but I know that it is one of four possible passwords.
Therefore my script needs to try all four passwords one after another. That means that if the first password fails the script should try the second password. If that fails again it should try the third. And if that fails it should try the fourth password.
Here is the code I have so far:
spawn telnet my_host
expect UserName {send admin\r}
expect PassWord [one of array passwords\r]
{if auth ok}
do something
{else}
try another password
expect -re #
send "logout\r"
expect eof
Can you help me achieve my aforementioned goal?