mattijs / node-rsync

Rsync wrapper for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with spawning /bin/sh - command not found

ben-eb opened this issue · comments

Thanks for this wrapper, seems like a better way than to manage a shell script instead. But I'm having difficulties trying to get it set up. I'm running this rsync command:

rsync -avzn ./ u@w.com:/var/www/blog

Which translates to this using node-rsync:

var rsync = new Rsync()
  .flags('avzn')
  .source('./')
  .destination('u@w.com:/var/www/blog');

rsync.execute(function(error, code, cmd) {
    // we're done
    console.log('Done.');
});

The problem is that the command just hangs. I think it's an issue with the spawn command on this line: https://github.com/mattijs/node-rsync/blob/master/rsync.js#L448 - if I try running this command:

/bin/sh rsync -avzn ./ u@w.com:/var/www/blog

I get this:

/usr/bin/rsync: /usr/bin/rsync: cannot execute binary file

And if specifying the -c parameter:

/bin/sh -c rsync -avzn ./ u@w.com:/var/www/blog

I just get the rsync help screen.

I wonder if it would be better to spawn the rsync command directly?

I'm using the latest version of node-rsync on node v0.10.26.

The rsync command is not spawned directly because shell escaping of arguments does not work then. If you specify a path that you want expanded when the command is execute (like *.js) it is not expanded when not executed in a shell. See the discussion in #15.

Could your bug be caused by rsync itself, or your installation (through sym-linking, shimming etc)?

Thanks for the reply but I decided just to use the rsync command directly, as it worked for me at the time.

Sorry the reply took a while.