#!/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;"
doneshell中调用expect小例子
原创juanmaoking 博主文章分类:shell脚本 ©著作权
©著作权归作者所有:来自51CTO博客作者juanmaoking的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:shell两个小练习
下一篇:ssh批量打通道
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Shell expect 实战案例
expect 实战
bash 服务器 生产环境 -
shell项目-分发系统-expect
使用expect远程操作
expect 远程操作 -
Linux expect与Shell交互
Linux expect与Shell交互
Linux expect与Shell交互
















