#!/bin/bash code_path='/root/' mysql_file='recharge*.gz' #mysql_file1='refund*.gz' hosts=`cat all.hosts` logname='/tmp/expect.log' rm -rf $logname for i in $hosts; do # echo $ipadd ipadd=`echo $i|awk -F, '{print $1}'` password=`echo $i|awk -F, '{print $2}'` cine_name=`echo $i|awk -F, '{print $3}'` expect -c" set timeout 600 spawn /usr/bin/scp -l 1024 $ipadd:${code_path}${mysql_file} /root/wzp/all/ log_file $logname expect { \"*yes*\" {send \"yes\r\"; exp_continue} \"*password*\" {send \"$password\r\";} } expect eof;" done
转载于:https://blog.51cto.com/alwaysyunwei/1283387