source: trunk/LMDZ.COMMON/libf/evolution/deftank/multiple_exec.sh @ 3603

Last change on this file since 3603 was 3579, checked in by jbclement, 4 weeks 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############################################################
5set -e
6trap '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
12script_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
18tempdir_name="Template"
19############################################################
20
21
22# Traverse all subdirectories, excluding the template
23i=0
24for 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
35done
36echo "Everything is executed: $i executions in total!"
37
Note: See TracBrowser for help on using the repository browser.