LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 08-29-2008, 02:07 PM   #1
uopjohnson
Member
 
Registered: Jun 2004
Location: San Francisco
Distribution: Slackware, Ubuntu, RHEL, OS X
Posts: 159

Rep: Reputation: 30
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.
Code:
if [ -z $2 ]; then
  echo "Direcotry Required"
  exit 1
fi
DIR="~/sites/$2/"
if [ ! -d $DIR ]; then
  echo "$DIR doesn't exist"
  exit 1
fi
RSYNC_CMD='/usr/bin/rsync'
ARGS='--delete -ua  --exclude ".svn/"'
case "$1" in
  private)
    SSH='-e "ssh"'
    DESTINATION="user@webtest:/var/www/html/user/$2"
    ;;
  shared)
    SSH='-e "ssh -p 8642"'
    DESTINATION="user@webtest:/var/www/html/testing/$2"
    ;;
  *)
    echo "Need to specific shared or private destination"
    exit 1
esac
CMD="${RSYNC_CMD} ${ARGS} ${SSH} ${DIR} ${DESTINATION}"
echo $CMD
I would like the last line to be
Code:
CMD
and that would just run the rcync command, unfortunately that doesn't work. I get the error
Code:
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,
 
Old 08-30-2008, 06:51 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
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?
 
Old 09-01-2008, 03:48 PM   #3
uopjohnson
Member
 
Registered: Jun 2004
Location: San Francisco
Distribution: Slackware, Ubuntu, RHEL, OS X
Posts: 159

Original Poster
Rep: Reputation: 30
I knew it was something small. Thanks. eval did the trick.
 
Old 04-23-2010, 02:16 AM   #4
Wizard09
LQ Newbie
 
Registered: Apr 2010
Location: Long Island, New York
Posts: 1

Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync -u Does it update the contents of a dir if that dir is changed? crazyivan Linux - Software 1 04-02-2008 04:08 AM
Bash Script test for empty dir uopjohnson Linux - Software 3 10-07-2005 07:45 PM
Bash script to compare dir contents Boffy Programming 2 08-02-2005 07:08 AM
bash script HELP - dnotify > rsync GuitsBoy Programming 5 01-28-2004 10:42 AM
bash script to rm all files in a dir keirobyn Programming 8 07-19-2002 08:53 AM


All times are GMT -5. The time now is 02:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration