|
Last change
on this file since 3618 was
3579,
checked in by jbclement, 10 months ago
|
|
PEM:
Improvement of the Bash script tools in the deftank with an automatic error detection which ends the script with a message.
JBC
|
-
Property svn:executable set to
*
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | #!/bin/bash |
|---|
| 2 | ############################################################ |
|---|
| 3 | ### Script to execute multiple scripts in subdirectories ### |
|---|
| 4 | ############################################################ |
|---|
| 5 | set -e |
|---|
| 6 | trap 'echo -e "\033[31mError: an issue occurred in the script on line $LINENO! Please review the command and try again.\033[0m"' ERR |
|---|
| 7 | |
|---|
| 8 | ############################################################ |
|---|
| 9 | # Modify here the parameters for the script |
|---|
| 10 | ########################################### |
|---|
| 11 | # Name of the file to execute in all subdirectories |
|---|
| 12 | script_name="launchPEM.sh" |
|---|
| 13 | #script_name="kill_launchPEM.sh" |
|---|
| 14 | #script_name="clean.sh" |
|---|
| 15 | #script_name="modify_startfi_orbit.sh" |
|---|
| 16 | |
|---|
| 17 | # Name of the template directory to skip |
|---|
| 18 | tempdir_name="Template" |
|---|
| 19 | ############################################################ |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | # Traverse all subdirectories, excluding the template |
|---|
| 23 | i=0 |
|---|
| 24 | for dir in */; do |
|---|
| 25 | if [ "$dir" == "$tempdir_name/" ]; then |
|---|
| 26 | continue |
|---|
| 27 | fi |
|---|
| 28 | if [ -f "$dir/$script_name" ]; then |
|---|
| 29 | echo "Executing $script_name in $dir..." |
|---|
| 30 | pushd "$dir" > /dev/null |
|---|
| 31 | ./$script_name |
|---|
| 32 | popd > /dev/null |
|---|
| 33 | ((i++)) |
|---|
| 34 | fi |
|---|
| 35 | done |
|---|
| 36 | echo "Everything is executed: $i executions in total!" |
|---|
| 37 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.