1

I have a bash script that I want to use to synchronise the local changes I made to my wordpress site using the rsync command. However, when I try to run the file in the command line, it only displays the contents of the file?

The script:

#!/bin/bash echo "Deploying website” SOURCE_DIR=“/my/local/path/to/files” TARGET_DIR="/remote/dir/location" TARGET_SERVER=“user@server -pPORT” echo "Synchronising" echo "" # rsync to live server rsync --progress --exclude ‘wp-config.php’ --stats --archive -z --compress --delete -t $SOURCE_DIR $TARGET_SERVER:$TARGET_DIR echo "" echo "Done” 

As I said, when executing: sh ./sync.sh in the command line, it only displays the contents of the script.

Can anyone spot where I'm going wrong? (Obviously, I change the path names and server in real file)

I've set the permissions to 755 and running on OSX

Any help would be greatly appreciated, thanks.

1
  • What if you just run ./sync.sh? Commented Sep 27, 2015 at 18:07

1 Answer 1

1

Unless it is just a copying error, you seem to have the wrong sort of double -quote at the end of the first echo (" at start doesnt match ” at end). This means the string parameter to echo goes on to the next ("), then continues with the next (") and so on until the whole file is echoed.

Ensure all double and single quotes have not been "magicked" by your editor.

Sign up to request clarification or add additional context in comments.

1 Comment

Hadn't check for this, thank you for the tip it worked. Hate it when it does this! If anyone was interested I changed the rsync command as well, to: rsync -e "ssh -p PORT" --progress --stats --archive -z --compress --delete -t /Path/to/local user@server:Path/to/remote

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.