How to call another bash script to run on a subfolder?
I want my bash script to run scripts located on a different folder. If it is also located on the same folder with my script, it will go like this:
on my $HOME folder: (this_script.sh, backup.sh, restore.sh, purge.sh) #!/bin/bash ./backup.sh ./restore.sh ./purge.sh But what if, on my $HOME folder: (this_script.sh) $HOME/scripts folder: ( backup.sh,restore.sh, purge.sh ) Below doesn't work... #!/bin/bash ./$HOME/scripts/backup.sh what the proper script for this? thanks in advance.. |
Code:
. /$HOME/scripts/backup.sh |
You can try this if you want to specify interpret the script with specific shell. for example bash shell
Quote:
Mardi V. Tamma |
The dot is merely a reference to where you are. All executable files not in your PATH need to be specified via the path to the script / executable:
Code:
/bin/bash |
You don't need ./$HOME.
If you are in $HOME Code:
scripts/backup.sh Code:
$HOME/scripts/backup.sh You might want to consider cd'ing to a known dir at the start of the script. NB: the 2nd example only works if you are logged in as the correct user (ie owner of $HOME). Otherwise, use a specific full path eg Code:
/home/user1/scripts/backup.sh |
Thanks for your help guys! well appreciated!
|
All times are GMT -5. The time now is 03:19 PM. |