标签:expect与shell嵌套 shell与expect嵌套
#!/bin/sh MAILDIR=/maildata/mailbox/gxm.cn/0 OLDDIR=/home/mailbox NEWDIR=/maildata/mailbox echo "" >/root/lostmailid echo "" >/root/lostmailidok for mailid in `cat /usr/local/kkmail/log/app/postman.log.2018-03-06 | awk -F" " '{print $4}' | grep -v "^program" | egrep -v "^[0-9]" | sed "s/\[//g" | sed "s/\]//g" | grep -v "gxm.cn$" | awk -F"-" '{print $1}'| uniq` do find $MAILDIR -name "*$mailid*" >>/root/lostmailid done cat /root/lostmailid | awk -F"/mailbox" '{print $2}' >>/root/lostmailidok for line in `cat lostmailidok` do /usr/bin/expect<<EOF spawn rsync -avz --progress "-e ssh -p 2222" $NEWDIR$line root@1.2.3.4:$OLDDIR$line expect { "yes/no" { send "yes\r"} "*password:" { send "123456\r" } } expect eof EOF done标签:expect与shell嵌套 shell与expect嵌套
原文地址:http://blog.51cto.com/net881004/2083863