意図的に間違ったパスワードを送信していないと仮定して、 exp_continue を使用します ループ構造として:
expect <<EOF
set passwds {foo bar baz}
set i 0
spawn ssh -t example@unixlinux.online$server_address "$*"
expect {
"continue connecting (yes/no)?" { send "yes\r"; exp_continue }
" password: " { send "[lindex $passwds $i]\r"; incr i; exp_continue }
eof
}
EOF