I have a script scriptA.sh that if a variable assume a certain value, it has to execute another script scriptB.sh that execute something and then call a scriptA.sh, that will call a scriptB.sh and so on.
I draw the execution:
ScriptA - ScriptB
|
|
_
|
_
|
|
_
|
_
I have tried in this way but process are never closed
ScriptA.sh
./scriptB.sh &
exit
ScriptB.sh
./scriptA.sh &
exit
And also this way but process are never closed
ScriptA.sh
./scriptB.sh && exit
ScriptB.sh
./scriptA.sh && exit
Any suggestion?
The actual scripts:
scriptA.sh:
#!/bin/bash
val=123
directory_path=`pwd`
script_name=$0
if [ $val -eq 123 ];then
echo "call B and exit"
./scriptB.sh $directory_path $script_name && exit 0
fi
scriptB.sh:
#!/bin/bash
directory_path=$1
exec_command=$2
cd
cd $directory_path
echo "call A and exit"
$exec_command && exit 0
#!/bin/bash val=123 directory_path=`pwd` script_name=$0 if [ $val -eq 123 ];then echo "call B and exit" ./scriptB.sh $directory_path $script_name && exit 0 fiscriptB.sh#!/bin/bash directory_path=$1 exec_command=$2 cd cd $directory_path echo "call A and exit" $exec_command && exit 0