-   Linux - General (
-   -   bash script to rsync remote dir with options (

uopjohnson 08-29-2008 01:07 PM

bash script to rsync remote dir with options
I have a bash script which takes some options and from them it syncs local changes up to the webserver using rsync. My problem is that I cannot get it to just run the rsync command I can only get it to echo the command out and then I copy paste to run it. Hopefully the example will make it all clear.

if [ -z $2 ]; then
  echo "Direcotry Required"
  exit 1
if [ ! -d $DIR ]; then
  echo "$DIR doesn't exist"
  exit 1
ARGS='--delete -ua  --exclude ".svn/"'
case "$1" in
    SSH='-e "ssh"'
    SSH='-e "ssh -p 8642"'
    echo "Need to specific shared or private destination"
    exit 1
echo $CMD

I would like the last line to be

and that would just run the rcync command, unfortunately that doesn't work. I get the error

Missing trailing-' in remote-shell command.
Which I assume is happening becuase my CMD string is not being put together well. Or because I have no idea what I'm doing :)
Any help appreciated,

acid_kewpie 08-30-2008 05:51 AM

well the error is, i think, an rsync error, but you're not actually *running* rsync at all there, if you're just echoing out a string which just happens to include the words to stdout. if you do an "eval $CMD" what happens?

uopjohnson 09-01-2008 02:48 PM

I knew it was something small. Thanks. eval did the trick.

Wizard09 04-23-2010 01:16 AM

I realize that this is an old thread but just wanted to say that I have the same issue and eval was the solution for me.

All times are GMT -5. The time now is 03:47 PM.