Expect script error send: Spawn id exp4 not open while executing
Assuming you're not sending a wrong password on purpose, use exp_continue
as a looping construct:
expect <<EOF
set passwds {foo bar baz}
set i 0
spawn ssh -t root@$server_address "$*"
expect {
"continue connecting (yes/no)?" { send "yes\r"; exp_continue }
" password: " { send "[lindex $passwds $i]\r"; incr i; exp_continue }
eof
}
EOF