简体   繁体   English

通过SSH使用rsync和spawn上传

[英]Uploading via SSH with rsync and spawn

Until very recently I have been using the following bash script to upload any edited files to my server. 直到最近,我一直在使用以下bash脚本将所有已编辑的文件上传到我的服务器。

./updatesite.sh ./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"

Usually it has worked fine. 通常它运行良好。 For some reason it has abruptly stopped working several weeks ago. 由于某些原因,它在几周前突然停止工作。 Here is the output it now provides: 现在是它提供的输出:

xuserx@xdomainx.com's password: 
building file list ... done

As you can see, No files are actually uploaded. 如您所见,实际上没有文件上传。 But if I paste that exact same command directly into my terminal window without the "spawn," its behavior changes and it uploads the files as usual. 但是,如果我将完全相同的命令直接粘贴到我的终端窗口中而没有“生成”,它的行为就会改变,并且照常上传文件。

Here is an example: 这是一个例子:

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$ 

Do you know what could be causing this? 你知道是什么原因造成的吗?

#!/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

It may be a timeout issue, so set the timeout to infinite. 可能是超时问题,因此请将超时设置为无限。 Since you don't have to interact with rsync in any way except for the password, just wait for it to finish (expect eof). 由于除了密码外,您无需与rsync进行任何交互,因此只需等待它完成(期望eof)即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM