13 Jun 15 00:06, you wrote to all:
Kh> ./sync_static_to_dev.sh
Kh> Rsyncing /server/assets with options: -vHrltD -e \'ssh -p 22\'
Kh> dgetsman@10.183.1.251:/server/assets /server/assets
Kh> Unexpected remote arg: dgetsman@10.183.1.251:/server/assets
Kh> rsync error: syntax or usage error (code 1) at main.c(1201)
Kh> [sender=3.0.6] Done -=-=-=-=-
Kh> #!/bin/sh
You can change this to:
#!/bin/sh -x
which will echo every command to stderr before it's executed.
Kh> WHICH='/usr/bin/which'
Kh> RSYNC=`$WHICH rsync`
It doesn't make any sense to do this. Just use
RSYNC=rsync
and let the shell find rsync.
Or you can point to it directly:
RSYNC=/usr/bin/rsync # (or /usr/bin/local/rsync on some systems)
Your script had a few other issues. I've greatly simplified it here:
=== Cut ===
#!/bin/sh -x
STATIC_ASSETS=/server/assets
SOURCE=10.183.1.251
RSYNC_VERBOSE=-v
#RSYNC=./param.py
RSYNC=rsync
RSYNC_USER=$USER
RSYNC_OPTS=-HrltD
RSYNC_EXTERN="-e ssh -p 22"
if [ -n "$1" ]; then
RSYNC_USER=$1
fi
$RSYNC "$RSYNC_VERBOSE" "$RSYNC_OPTS" "$RSYNC_EXTERN"
"$RSYNC_USER"@"$SOURCE":"$STATIC_ASSETS" "$STATIC_ASSETS"
=== Cut ===
A couple of things to note:
1. Don't bother quoting single words when setting variables
2. Use double quotes for all the parameters in the final call to rsync
3. -e ssh -p 22 is actually the default for rsync, so it's redundant, and just
leaving this part out would've fixed your problem
4. param.py is a simple Python script I wrote for testing in place of rsync,
just to print out all the arguments as recieved by the external program:
=== Cut ===
#!/usr/bin/env python
import sys
print sys.argv
=== Cut ===
(You could do this with a shell script instead, but then the arguments might
get escaped again, so I don't trust it.)
So if I set:
RSYNC=./param.py
I get:
$ ./sync_static_to_dev.sh
+ STATIC_ASSETS=/server/assets
+ SOURCE=10.183.1.251
+ RSYNC_VERBOSE=-v
+ RSYNC=./param.py
+ RSYNC_USER=ozzmosis
+ RSYNC_OPTS=-HrltD
+ RSYNC_EXTERN='-e ssh -p 22'
+ [ -n '' ]
+ ./param.py -v -HrltD '-e ssh -p 22' ozzmosis@10.183.1.251:/server/assets
/server/assets
['./param.py', '-v', '-HrltD', '-e ssh -p 22',
'ozzmosis@10.183.1.251:/server/assets', '/server/assets']
Which is correct. :-)
Regards
Andrew
--- GoldED+/BSD 1.1.5-b20130910
* Origin: Blizzard of Ozz, Melbourne, Victoria, Australia (3:633/267)
|