Jithin Jithin - 1 year ago 102
Bash Question

To execute multiple bash scripts in diff directories using one single bash script

I have multiple bash scripts to bounce Jboss instances in multiple directories. These scripts accepts arguments

start | stop | reload | status | restart.


I wish to have a single bash script which accepts the same arguments and execute all the 5 scripts mentioned above.

/opt/singlescript.sh start ---- must execute all the 5 scripts with start argument.

Any help would be much appreciated.

Answer Source

It would look something like this. There are multiple ways to do this and this is just one way

echo "invoking x/X_FE with $1"
sh /opt/xyz/x/X_FE.sh $1

echo "invoking x/X_BE with $1"
sh /opt/xyz/x/X_BE.sh $1

echo "invoking y/Y_FE with $1"
sh /opt/xyz/y/Y_FE.sh $1

echo "invoking x/Y_BE with $1"
sh /opt/xyz/y/Y_BE.sh $1

echo "invoking z/Z_FE with $1"
sh /opt/xyz/z/Z_BE.sh $1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download