Nadine
Nadine

Reputation: 787

How to run multiple commands in one bash file?

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?

Upvotes: 0

Views: 464

Answers (1)

mb21
mb21

Reputation: 39189

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

Upvotes: 2

Related Questions