On Fri, 5 Dec 2008 09:58:34 +1100, Amos Shapira wrote:
>
> I've been doing shell programming for years but this got me stomped
> (simplified version):
>
> rsync="/usr/bin/rsync -navHz --delete --delay-updates --bwlimit=256 -e
> 'ssh -i /root/rsync.id'"
> local=/mnt/data/html/minicpan
> copyto="test01:$local"
> $rsync $local/ $copyto/
>
> When I execute this script with "sh -vx" the final lines are:
>
> $rsync $local/ $copyto/
> + /usr/bin/rsync -navHz --delete --delay-updates --bwlimit=256 -e
> ''\''ssh' -i '/root/rsync.id'\''' /mnt/data/html/minicpan/
> test01:/mnt/data/html/minicpan/
> Missing trailing-' in remote-shell command.
> rsync error: syntax or usage error (code 1) at main.c(361) [sender=3.0.4]
>
> It looks like the shell splits the value of "$ssh" into words and adds
> quoting around them.
>
> The rsync command line I'd like to see is:
>
> /usr/bin/rsync -navHz --delete --delay-updates --bwlimit=256 -e ''ssh
> -i /root/rsync.id'' /mnt/data/html/minicpan/
> test01:/mnt/data/html/minicpan/
I don't think you want double apostrophes but a single quote.
1. You can solve your problem by putting the ssh command in RSYNC_RSH like this
export RSYNC_RSH="ssh -i /root/rsync.id" instead of using -e.
2 You can put the ssh command in a variable (no eval or functions):
SSH="ssh -i /root/rsync.id"
rsync="/usr/bin/rsync -navHz --delete --delay-updates --bwlimit=256 -e"
local=/mnt/data/html/minicpan
copyto="test01:$local"
$rsync "$SSH" $local/ $copyto/ ## note the quotes around $SSH
3. You can change the IFS variable to use : (or another character)
instead of space, something like this (try it, I did):
rsync="/usr/bin/rsync:-navHz:--delete:--delay-updates:--bwlimit=256:-e:ssh -i
/root/rsync.id"
local=/mnt/data/html/minicpan
copyto="test01:$local"
IFS=":" # use only : (not space) to separate tokens
$rsync $local/ $copyto/ # you can use : or space for extra arguments
Note. Be warned not to change the IFS. If you must do it (like in my 3rd
solution), remember to set it back to what it was as soon as possible (its
default - not be changed - value is " \t\n").
So do: SVIFS="$IFS"
IFS="new-value"
<commands with changed IFS>
IFS="$SVIFS" # the quotes are essential
Ehud.
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]