1

I have the following script:

#!/bin/bash        
PATH=...
echo 'Syncing database dumps'
rsync ssh [email protected]:/test/ /test
echo 'Creating symlink'
ln -s test /tmp/test

Only the first command and all echo's are run. If I comment out the first command, then the symlink command is run:

#!/bin/bash        
PATH=...
echo 'Syncing database dumps'
#rsync ssh [email protected]:/test/ /test
echo 'Creating symlink'
ln -s /test /tmp/test

The rest do not run. Any ideas why?

Edit, based on recent comment, added the -v option to the symlink command. Now I can see that all the commands do run. But they do not run in the sequential order they are set in. The symlink command will run BEFORE the rsync command has finished. How can I set the order so the symlink command is only run after the rsync command has finished?

4
  • 1
    How can you tell it doesn't run? Do you have an error message? Did you try to run ln with the -v option (the verbose option)? I think we're not psychics, and you should provide more information. Commented Dec 2, 2012 at 11:33
  • I have updated the comment. Adding the -v option has made my problem clearer. Commented Dec 2, 2012 at 11:57
  • The commands do run in sequential order! How can you tell they don't run in the order they appear in your file? How can you tell ln is executed before rsync ends? Do you have a & symbol at the end of your rsync command? Once again, we're not psychics ;-). Commented Dec 2, 2012 at 12:01
  • Nope, the script is as it is. And the symlink script was running before the rsync one because it appears rsync was running in the background. Thank you for your comments, they have clarified the problem for me and made me realise I need to add more info in the future! :) Commented Dec 2, 2012 at 12:12

1 Answer 1

3

Try rsync's --blocking-io option, i.e.

rsync ssh --blocking-io [email protected]:/test/ /test

Alternatively you could use scp if your protocol is ssh anyway

scp [email protected]:/test/ /test
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.