![](/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.