expect set timeout -1 永不超时

. ~/.bash_profile
passwd='xxx'

expect <<!
set timeout -1
spawn  rsync -avH /webapps/Seeyon/A8/base/upload/ root@120.26.93.217:/webapps/Seeyon/A8/base/upload/
expect {
    "(yes/no)?" {
        send "yes
"
        expect "password:"
        send "$passwd
"
    }
        "password:" {
        send "$passwd
"
    }
 }
expect eof
exit
!

原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200377.html