Comments (15)
Hi, I think your problem might be caused by the option value escaping.
I've prepared a fix for that in pull request #13
Does it solve the issue?
from node-rsync.
I've done some tests with a similar command and in my case I was getting error code 12 without the fix.
However, there is yet another issue: if you want to use a file name pattern like "*.gz" you'll have to expand it on your own using something like https://www.npmjs.org/package/glob
It would have worked in older versions of node-rsync because, as it used exec() to launch the rsync command, it was being parsed and expanded by the shell, but now using spawn() instead there is no shell to do that work for you.
from node-rsync.
The first thing that sprung to my mind was path expansion. It probably does not work with the shell the command is run in. Like @AlbertoGP says you basically have to expand the paths in your node script manually and use a list of files instead of a "globbed" path.
I'll take a look at your PR @AlbertoGP because shell escaping should work properly.
@akayami What shell do you use? (bash/zsh/fish?)
from node-rsync.
The point is that spawn
does not use any shell.
You might assume that node's exec
and spawn
correspond to the POSIX function families exec*
and spawn*
, but if you look closely you'll notice that there is no exec*
that takes the whole command line as argument, but always each argument separately just like spawn*
:
exec_: http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
spawn_: http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html
The documentation for exec
says:
http://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback
Runs a command in a shell and buffers the output.
If you look in spawn
, there is no mention of shells. I guess it could be more explicit to avoid confusions.
http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
Node's child_process.exec()
is more similar to system()
:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html
I thought they might use that function, but it turns out that they just launch the shell executable with your command line as an argument as described in the link above for system()
. You can see it in node's source code:
https://github.com/joyent/node/blob/937e2e351b2450cf1e9c4d8b3e1a4e2a2def58bb/lib/child_process.js#L589
Thus it does not matter what shell you have selected in your user account: it'll always use cmd.exe
in Windows and /bin/sh
anywhere else.
from node-rsync.
@AlbertoGP wow, good info, usefull to know. I hadn't looked at the source yet.
After some testing I think the error 14 is due to the escaping of the --rsh
option, making it very related to #12. I'm working on fixing the escaping to fix #11 and #12.
from node-rsync.
If you mean the function escapeShellArg()
yes, removing the quoting there solves some simple cases, and others have done it as a quick fix: (that's also the first thing I tried)
https://github.com/yottagroup/node-rsync/commit/8423412111f1642728da858258ddc7c403e8cfac
https://github.com/mattijs/node-rsync/network
from node-rsync.
Another alternative is to launch the whole command line under a shell.
See PR #15, which is much less invasive than #13 and gets us file name globbing for free, just like in the good old days of using exec()
.
from node-rsync.
@AlbertoGP What does removing the escapeShellArg()
not fix? I don't see a real difference in outcome with your PR #13. The outcome is the same as these changes: c2e4d82
from node-rsync.
You already saw it, but in case someone arrives here from a search engine, the answer is at #13 (comment)
In short, it's short options with arguments.
from node-rsync.
@akayami master
has been updated to include fixes for your problem. Could you retest your command with the master code to see if it works?
from node-rsync.
@mattijs Hi. Your fix works perfectly. Thank you very much !
Do you need to push it in some way to be available using NPM ? I have no clue how that part works, but I would like to be able to specify the correct version in my package.json file.
from node-rsync.
@akayami I'll publish a new version to NPM as soon as possible so you can set a version in your dependencies.
If you want to use the latest version already you can set the version in your package.json to the master branch. This will make you use the latest version (see https://www.npmjs.org/doc/files/package.json.html#Git-URLs-as-Dependencies).
from node-rsync.
Just subscribed to notifications on this issue. I'm having the very same problem, but when using sshpass
as shell. Also looking forward the NPM package update.
Thank you, guys!
from node-rsync.
I just released v0.3.0
as a github tag (https://github.com/mattijs/node-rsync/tree/v0.3.0) and published a new version to NPM. You can set your package.json
versions to 0.3.0
π
from node-rsync.
Awesome, Mattijs. Thank you very much!
from node-rsync.
Related Issues (20)
- Escaping $ in *nix platforms HOT 2
- Reporting --stats? HOT 1
- Rsync with password protected resources HOT 1
- File name escaping seems to fail HOT 7
- OnProgress event HOT 1
- transfer files from local to remote, prompt password HOT 1
- Allow overriding of environment variables being passed to child_process.spawn & rsync
- rsync hangs for unexpected time
- kill does not work HOT 3
- Support for --rsync-path HOT 1
- enhancement: custom streams
- Stderr goes to Stdout
- What is the time required to rsync a file? What is the speed I should expect ?
- How do I get progress output? Only seeing <Buffer ..... in stdout HOT 2
- Custom port ? HOT 2
- how to build a β-eβ optionοΌ HOT 1
- When I use rsync in winows system, there is an unsolvable error HOT 4
- huntr.dev - Code Injection HOT 2
- How to use a jump host in this library HOT 1
- cygwin path with space as source path does not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-rsync.