I have a script that executes same commands on multiple servers via ssh .
spawn ssh [lindex $argv 0]
send "sudo /usr/sbin/useradd ytkatchen"
expect "password:"
send "Unix\@999\r"
My password is not same/alike for all servers . I have 2 different passwords for a long list of servers .
My requirement is the script should make ssh connection and use correct valid password to keep the job going .
It should not execute if the password is wrong rather it should try other password and keep going.