I've prepared a shell script to run a Java file. I've given Java path, class path and dependencies. I'm executing the file based on a condition.
Following is the code snippet. The code gets executing, but the control is not coming out of the prompt.
CMD=""$JRE_BIN_PATH/java" $SP -cp $CP org.aditya.test.MainClass "$@""
if [ "$1" == 'server' ] && [ "$2" == 'start' ]
then
$CMD &
elif [ "$1" == 'process' ]
then
$CMD &
else
$CMD
fi
Command hangs when if
and elif
executes, since it is using '&' at the end. But if the control goes to else (without '&') control coming out immediately. I've removed '&' and everything works fine. My question here is, what is the use of '&' at the end of CMD. Why it is causing the problem.