I'm not sure I understand. What keeps you from supplying the node info to Mod_1 and _2 ?
BTW - running those with sh when bash is available loses many of the advanced features that bash provides.
#!/usr/bin/env bash
for mS in myScriptA.sh myScriptB.sh
do
[ -x "$mS" ] && \
./$mS "$1" & || \
$SHELL $mS "$1" &
done
This checks myScriptA and myScriptB wether the files have execution flag or not.
If it has, just start the script, if it hasent, use its very own $SHELL to start it.
Oh yeah, and pass the first argument passed those scripts too and sends them to background so they run simultaniously.
#!/usr/bin/env bash
for mS in Mod_1.sh Mod_2.sh
do
[ -x "$mS" ] && \
./$mS "$1" & || \
$SHELL $mS "$1" &
done
Getting following error......
[KTTM:/home/view/bin] Mod_new.sh NODE_5 ======>i have to run file like this
./Mod_new.sh: line 6: syntax error near unexpected token `||'
./Mod_new.sh: line 6: ` ./$mS "$1" & || \'
Please use CODE tags, the icon with the text 'code' on it.
The iCodes are nice to provide a sample code without the need of line break, not applicable for script or debug output!
Any luck making brackets ./$mS "$1" & so it looks like: (./$mS "$1" &) ?
If not, rewrite that block to:
if [ -x "$mS" ] ; then
./$mS "$1" &
else
$SHELL $mS "$1" &
fi
You do NOT want to name your script Mod_1.sh and have it invoke Mod_1.sh and Mod_2.sh . You are not ready to handle recursive scripts yet.
You could make your script relatively complex and try to parse the single operand you have suggested passing to your script...
Or, assuming that MOD is a constant in all of your calls and does not need to be passed as an operand to your script, you can make it simple on yourself and invoke your script something like this:
Mod_NEW.sh 5 6 7 8 10 11 55 48
with Mod_NEW.sh containing something like:
#!/bin/sh
for node in "$@"
do Mod_1.sh MOD_"$node"
Mod_2.sh MOD_"$node"
done
This will work with any shell that accepts basic Bourne shell syntax such as ash , bash , dash , and (my preferred shell) ksh .