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\n" expect "password:" send "$passwd\n" } "password:" { send "$passwd\n" } } expect eof exit !