Caller Script should produce and email from 4 different script within it

Hi

I wrote a shell script , which includes one output file which is emailed back to me , when the script runs .

Now i want to slip the script into 4 different shell scripts each of which taking the parameter PROD or DEV, and include all the 4 different shell scripts in a caller script.

The idea behind doing like this is , if their is problem with one script atleast the other script should not stop from running .

Now my whole idea is still to get only one email when we run the caller script .
So how to direct the output of each script such a way , that we get only one output file and one email from running the caller.

Pls help me , with this .

Also , can the common local variables to all the 4 shell scripts be in the caller script and code where it chooses the parm PROD or DEV ..

is so , how would the 4 scripts take those local variables and use them to run itself .

ANy help is appreciated ..

In sh and bash there's no way to pass parameters from child to parent, neither from subshells to master shell.
The turnaround i use is to write parameters in an appropriate form to a file. The form can be just values of the variables or strings like "var_A=value" which can be treated after reading by 'eval'.
If you don't write to disk, maybe you have a /dev/shm directory which is a world-writeable "ramdisk" which can be useful to store temporary files or parameters.
The problem you can encounter is when two ore more scripts try to write simultaneously to the file, if there's only one.

I am guessing this is what you are looking for
## In your parent script e.g. par.sh
# call chi.sh
. ./chi.sh
echo $var_in_chi

## In you child script e.g. chi.sh
export var_in_chi=100

So now if you run par.sh you will see a 100.
Please note, your parent script should call the child script with a ". "

The ". " doesn't make a call of the script but sources the script. ". script.sh" is an equivalent of "source script.sh". It doesn't launch any new process, it's like an "include" in C.