Jon*_*onn 1 ssh bash rsync expect uploading
直到最近,我一直在使用以下bash脚本将所有已编辑的文件上传到我的服务器。
./updatesite.sh
#!/usr/bin/expect -f
spawn rsync -av -e ssh "/(...)/webs" xusernamex@xdomainx.com:/home/webs
expect "password:"
send "xpasswordx\r"
expect "*\r"
expect "\r"
Run Code Online (Sandbox Code Playgroud)
通常它运行良好。由于某些原因,它在几周前突然停止工作。现在是它提供的输出:
xuserx@xdomainx.com's password:
building file list ... done
Run Code Online (Sandbox Code Playgroud)
如您所见,实际上没有文件上传。但是,如果我将完全相同的命令直接粘贴到我的终端窗口中而没有“生成”,它的行为就会改变,并且会像往常一样上载文件。
这是一个例子:
Squid:~ John$ rsync -av -e ssh "/(...)/webs" xuserx@xdomainx.com:/home/xuserx
xuserx@xdomainx.com's password:
building file list ... done
webs/somefile.txt
sent 878 bytes received 42 bytes 204.44 bytes/sec
total size is 96409 speedup is 104.79
Squid:~ John$
Run Code Online (Sandbox Code Playgroud)
你知道是什么原因造成的吗?
#!/usr/bin/expect -f
# exp_internal 1 ;# uncomment to turn on expect debugging
set timeout -1
spawn rsync -av -e ssh "/(...)/webs" xusernamex@xdomainx.com:/home/webs
expect "password:"
send "xpasswordx\r"
expect eof
Run Code Online (Sandbox Code Playgroud)
可能是超时问题,因此请将超时设置为无限。由于除了密码外,您无需与rsync进行任何交互,因此只需等待它完成(期望eof)即可。
| 归档时间: |
|
| 查看次数: |
4813 次 |
| 最近记录: |