I have this code but I don't understand it very well.
Can you explain to me how the finish variable gets the value.
what does this assignment "finish=$?" mean?
or if they have any documentation to help me understand.
Thanks in advance.
#!/usr/bin/bash
/usr/bin/java -jar Report.jar $user $pass $base $dateini $datefin $iphost >> file.log 2>&1
finish=$?
if [ $finish -eq 0 ]; then
echo "Report executed successfully" >> file.log
exit 0
else
echo "There was an error in the report" >> file.log
exit 1
fi
CodePudding user response:
The exit status of the last command you ran (/usr/bin/java -jar ...
) is stored in the special parameter $?
.
Commands executed by the shell script or user have a exit status being either 0 (meaning the command was successful without errors), or a non-zero (1-255) value indicating the command was a failure.
Check here for further information