[英]How to move the directory to the remote using rsync?
It was bit confusing how to ask this question. 如何问这个问题有点令人困惑。 I have a folder named as exec
, inside exec
folder I have files as 我有一个命名为文件夹exec
,里面exec
文件夹我有文件作为
node_modules
exec.js
hello.txt
package.json
AIM : I want to move this folder exec
to my remote machine using rsync. 目的 :我想使用rsync将这个文件夹exec
移到我的远程计算机上。
In exec.js
I wrote the logic in order to move the folder to my remote,(before that I checked whether rsync is working by taking a dummy txt file and made it to move to remote machine which was achieveable for me). 在exec.js
我编写了逻辑以将文件夹移动到我的远程服务器(在此之前,我通过获取虚拟txt文件检查rsync是否正在工作,然后将其移动到对我而言可以实现的远程计算机上)。
exec.js exec.js
console.log('1');
var exec = require('child_process').exec;
exec('node -v'+ '&& dir'+ '&& rsync -avz -e "ssh -o StrictHostKeyChecking=no\
-o UserKnownHostsFile=/dev/null" --progress\
hello.txt ec2-user@xx.xxx.xx.xxx:/home/ec2-user/exec',\ //how to include the folder exec in place of hello.txt, so that my whole folder moves to remote?
function (error, stdout, stderr) {
console.log('stdout', stdout);
if (error !== null) {
console.log('exec error: ', error);
}
});
Found the way out of this question, 找到了解决这个问题的方法,
'*' will work in place of hello.txt. “ *”将代替hello.txt。
console.log('1');
var exec = require('child_process').exec;
exec('node -v'+ '&& dir'+ '&& rsync -avz -e "ssh -o StrictHostKeyChecking=no\
-o UserKnownHostsFile=/dev/null" --progress\
* ec2-user@xx.xxx.xx.xxx:/home/ec2-user/exec',\ //how to include the folder exec in place of hello.txt, so that my whole folder moves to remote?
function (error, stdout, stderr) {
console.log('stdout', stdout);
if (error !== null) {
console.log('exec error: ', error);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.