У меня есть пример, который захватывает код выхода из весеннего пакета, вызываемого из сценария Shell.
JOB_RET = $ ?.
Надеюсь, это поможет.
#!/bin/bash
#
# Launch Spring Batch
#
#Get the absolute path to the folder containing the folder this script is located in
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HOME_DIR=$(dirname $BIN_DIR)
BATCH_HOME=$HOME_DIR
RUN_ID=$(date +"%Y-%m-%d %H:%M:%S")
LOG4J_CONF=file:$HOME_DIR/config/log4j.xml
function show_help {
echo "usage: $BASH_SOURCE -o <options> -d <month> -y <year>"
echo " where command is one of the following: "
echo " options - Options (such as autoLogin|autoLogOut)."
echo " month - Enter a month as Job param."
echo " year - Enter a year as Job param."
exit 1
}
# Read command line options
OPTIND=1 # Reset in case getopts has been used previously in the shell.
while getopts "ho:d:y:" opt; do
case "$opt" in
h)
show_help
exit 0
;;
d) options=$OPTARG
;;
s) month=$OPTARG
;;
o) year=$OPTARG
;;
esac
done
JOB_PARAMS="options=$options month=$month year=$year"
#Run the job
$JAVA_HOME -cp "$(echo $HOME_DIR/lib/*.jar | tr ' ' ':') \
-Djava.security.properties==$JAVA_SECURITY_FILE \
-Dlog4j.configuration=$LOG4J_CONF \
-DBATCH_HOME=$HOME_DIR -d64 \
org.springframework.batch.core.launch.support.CommandLineJobRunner batch-jobs.xml <job-name> run.id="$RUN_ID" ${JOB_PARAMS} > $HOME_DIR/logs/stdout.log 2>&1
JOB_RET=$?
echo "Job returns $JOB_RET" >> $HOME_DIR/logs/stdout.log
exit $JOB_RET
https://bigzidane.wordpress.com/2016/06/26/launch-spring-batch-job-from-shell-script-sh/