The ha_execute_cmd() function executes the command specified by $HA_CMD, which is set in the action script. $1 is the string to be logged. The function returns 1 on error and 0 on success. On errors, the standard output and standard error of the command is redirected to the log file.
ha_execute_cmd()
{
OUTFILE=${HA_SCRIPTTMPDIR}/script.$$
${HA_DBGLOG} $1
eval ${HA_CMD} > ${OUTFILE} 2>&1;
ha_exit_code=$?;
if [ $ha_exit_code -ne 0 ]; then
${HA_LOG} "$1 failed"
${HA_LOG} `cat ${HA_SCRIPTTMPDIR}/script.$$`
fi
${HA_DBGLOG} "${HA_CMD} exited with status $ha_exit_code";
rm ${OUTFILE}
return $ha_exit_code;
} |
The ha_execute_cmd_ret() function is similar to ha_execute_cmd, except that it places the command output in the string $HA_CMD_OUTPUT.
ha_execute_cmd_ret()
{
${HA_DBGLOG} $1
HA_CMD_OUTPUT=`${HA_CMD}`;
ha_exit_code=$?;
${HA_DBGLOG} "${HA_CMD} exited with status $ha_exit_code";
return $ha_exit_code;
} |