Question : bash shell-- passing var back to shell, to pass to another script

i'm having to tweak a bash script, which I dont' know much about... this script, in turn, calls about 5 other shell scripts.

i need the last shell script to return a variable to the calling script, and then that script will use it to pass on to the next script in the line... i.e. something LIKE THIS (though this syntax is invalid, since I don't know bash!!)... note script 3 returns a value, for script 4 to use.

specifically I am looking for these two answers:

1. what do I put at the end of script 3, to return the result to the caller

2. what is the correct syntax for my master script (above) so I can pass that result on to script 4

thank you very much---
E
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
# master bash script, that calls the others
$SCRIPTDIR/do_script_1.sh parameter1
$SCRIPTDIR/do_script_2.sh
 
# note next line, script 3 returns a result
$RESULT = $SCRIPTDIR/do_script_3.sh  
 
# pass that result to script 4
$SCRIPTDIR/do_script_4.sh $RESULT
Open in New Window Select All

Answer : bash shell-- passing var back to shell, to pass to another script

A child script can't modify the value of a variable set in the parent.

To achieve want you want, it looks like you'll need to use a temporary file, eg:

In the master script

$SCRIPTDIR/do_script_3.sh
result=`cat /tmp/result`

In do_script_3.sh

echo "Some output"
echo "value to be returned" >/tmp/result
Random Solutions  
 
programming4us programming4us