how to exit out of the calling Shell Script
Hi All,
I have 2 shell scripts, script1.sh and script2.sh. I call script2.sh from within script1.sh ( by simple ./script2.sh command).
Based on some condition, i use exit 0 to exit out of script2.sh. I was trying to find if i can exit out of script1.sh as well at once.
Can anyone please clarify, if there is a way to do that.
below is the example
script1.sh
#!/bin/bash
echo "Before ..."
./script2.sh
echo "After ..."
script2.sh
#!/bin/bash
# check if a file exists and is not empty, if not empty exit (but i want to exit out of script1 as well )
if [[ -s err.log ]]; then
echo " There was problem file is empty "
cat err.log
echo " The Script will Exit. Please fix the issue and run again..."
exit 0
else
echo " file is Empty. Proceeding with the next step... "
fi
----
When i execute below is the output
Before ...
There was problem file is empty
The Script will Exit. Please fix the issue and run again...
After ...
I am trying to exit out of script1.sh as well so that i dont print "After ..."
thanks for the help
|