shell脚本嵌套expect脚本
cat ssh.sh
#!/bin/bash
for i in {201..202}
do
/usr/bin/expect <<EOF
set timeout 30
spawn ssh-copy-id -i 192.168.10.$i
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "123\r" }
}
expect eof
EOF
done
exp_continue皮牌多次相同条件;例如匹配多次yes/no而不是匹配一次之后经行下一个expect