I use Java to call a shell script in remote machine.
I want to know if the shell execute failed. But I found that, checking the return code $?
after the script is finished doesn't work. $?
only indicate the last command's result code in the script.
So even a command execute failed, but the last command execute success. I can't find it. I want to know how to solve the problem?
Need I check the result code for every command in shell? And if one command execute failed, exit the script?
$?
returns the exit status of the last command executed in a script or in a function. Exit status.