首先安装好expoect,yum -y install expect
#!/bin/bash
for i in 192.168.30.{22..23}
do
/usr/bin/expect <<-EOF
spawn scp /root/99.sh root@$i:/root
expect
{
“yes/no" { send "yes ";exp_continue }
"password" { send "666666 " } }
expect eof
EOF
done
首先安装好expoect,yum -y install expect
#!/bin/bash
for i in 192.168.30.{22..23}
do
/usr/bin/expect <<-EOF
spawn scp /root/99.sh root@$i:/root
expect
{
“yes/no" { send "yes ";exp_continue }
"password" { send "666666 " } }
expect eof
EOF
done