Reputation: 10173
There's no shortage of questions regarding rsync invocation, but I don't see anything helpful in tens that I've read, so this is the command I'm struggling with:
$ rsync -av -e 'ssh -i key.id_dsa -l root' root@server:/dir/file /tmp/file
It works from bash. I invoke it from Groovy code using the String.execute()
method and it fails as follows:
command exit code: 1
rsync command output:
rsync command error output:
Unexpected remote arg: root@server:/dir/file
rsync error: syntax or usage error (code 1) at main.c(1348) [sender=3.1.0]
Apparently, the -e
switch and its value is the problem: commands such as rsync -av -r --progress root@server:/dir/file /tmp/file
works flawlessly.
Question 0: why is the -e
parameter special?
Question 1: how do I make it work?
Upvotes: 1
Views: 2189
Reputation: 171154
I'm guessing the -e
switch is something fancy required by the bash shell... So to invoke the command with the bash shell behind it, you'd need to use the List
form of execute
like so:
["bash", "-c", "rsync -av -e 'ssh -i key.id_dsa -l root' root@server:/dir/file /tmp/file"].execute()
And that should get it running (I invariably use this form, as it always seems to be less error-prone than the String.execute()
form)
Upvotes: 1