1> ssh-expect.exp
#!/usr/bin/expect
set i [lindex $argv 0]
set timeout 30
spawn ssh root@slave$i
expect "(yes/no)?"
send "yes\r"
expect -re "\]($|#)"
send "exit\r"
interact
2 do_ssh.sh
#!/bin/bash
for i in {01..03}
do
echo $i
./ssh-expect.exp $i
done