. ~/.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
!
expect set timeout -1 永不超时
最新推荐文章于 2024-07-31 16:26:34 发布
通过在expect脚本中设置timeout为-1,可以确保rsync命令在执行远程文件同步时不会超时。该脚本示例中,expect会发送密码并等待rsync命令完成。
摘要由CSDN通过智能技术生成