![](/img/trans.png)
[英]Rsync to NFS directory via bastion with SSH as SSH user but write as www-data
[英]Uploading via SSH with rsync and spawn
直到最近,我一直在使用以下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"
通常它运行良好。 由于某些原因,它在几周前突然停止工作。 现在是它提供的输出:
xuserx@xdomainx.com's password:
building file list ... done
如您所见,实际上没有文件上传。 但是,如果我将完全相同的命令直接粘贴到我的终端窗口中而没有“生成”,它的行为就会改变,并且照常上传文件。
这是一个例子:
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$
你知道是什么原因造成的吗?
#!/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
可能是超时问题,因此请将超时设置为无限。 由于除了密码外,您无需与rsync进行任何交互,因此只需等待它完成(期望eof)即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.