Shell script 1.sh is like
#/bin/bash
if some java command;
then
exit 1;
else
exit 0;
fi
Shell script 2.sh will determine its execution based on the result (1 or 0) from 1.sh
#/bin/bash
readyToDoSomethingIfOne=$(1.sh)
if($readyToDoSomethingIfOne=="1");
then
echo "ready to go";
else
echo "Not ready yet" ;
fi
It looks like exit command from 1.sh does not pass the value to 2.sh. Is there any good way to do so?
By the way, 1.sh and 2.sh have to be separated for business reasons.
Thanks
$?, not captured in$()(which gets content sent to stdout). In general, though, if you wanted to know if something succeeded or not, you don't need to check$?explicitly --if some_commandwill take the true branch if$?is 0 after runningsome_command, the else branch otherwise..shextensions -- first, commands don't conventionally have extensions at all in UNIX (you don't runls.elf); second, bash is not POSIX sh, and someone runningsh foo.shrather thanbash foo.shwould be in for an unwelcome surprise if you used any features not available in the barebones standard form of the language.exit 0should be used on success, andexit 1on failure.