#!/bin/bash

Detailtxt="test.txt"
while read line

do

   dest=`echo $line|awk '{print $1}'`
   ip=`echo $line|awk '{print $2}'`
   /usr/bin/expect <<-EOF
   spawn scp /etc/hosts root@ip:$dest
   expect { 
"yes/no" {send "yes\r";exp_continue}
"password:" { send "密码\n" }
}

   expect "*#"
EOF


done < $Detailtxt

其中test.txt格式如下

/tmp ip地址

相关文章:

  • 2021-07-14
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-08
  • 2021-07-07
  • 2021-06-23
  • 2022-02-09
  • 2021-04-28
相关资源
相似解决方案