I have two scripts; - export_simple_script_wrapper.sh - export_simple_script.sh
export_simple_script.sh seems to work every time and in the logs shows the correct "$RC" (=$?) every time for the right failure (or success).
export_simple_script_wrapper.sh works, by calling export_simple_script.sh but the log output and "if" logic proves that it is always getting success "0" when export_simple_script.sh tells other wise.
I have provided (I hope) enough log and script info below for your help in finding my problem.
(#2.) ---FORCE "export_simple_script.sh" - BAD ORACLE PASSWORD
[oracle@(protected) tmp]$ sh export_simple_script_wrapper.sh cleaning up RETURN CODE: 0
[oracle@(protected) tmp]$ more export_simple_script_wrapper.sh.log.SCRIPT RETURN CODE: Set initial Return Code - RC for this script. 1
ORACLE EXPort SUCCEEDED!: 0 0
[oracle@(protected) tmp]$ more exp.log.SCRIPT ... EXP-00004: invalid username or password EXP-00005: all allowable logon attempts failed EXP-00000: Export terminated unsuccessfully RETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE. 1
ORACLE EXPort FAILED!: 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7232.39"> <TITLE>RE: PART II: - Beyond a basic Oracle EXP/IMP shell script: Error Handling & Exit Status?</TITLE> </HEAD> <BODY> <!-- Converted from text/plain format -->
<P><FONT SIZE=2>Guys, I'm stuck?<BR> <BR> I have two scripts;<BR> - export_simple_script_wrapper.sh<BR> - export_simple_script.sh<BR> <BR> <BR> export_simple_script.sh seems to work every time and in the logs shows the correct "$RC" (=$?) every time for the right failure (or success).<BR > <BR> export_simple_script_wrapper.sh works, by calling export_simple_script.sh but the log output and "if" logic proves that it is always getting success "0" when export_simple_script.sh tells other wise.<BR> <BR> I have provided (I hope) enough log and script info below for your help in finding my problem.<BR> <BR> Thanks in advance,<BR> <BR> Chris Marquez<BR> Oracle DBA<BR> <BR> <BR> ++++++++++++++++++++++++++++++++<BR> export_simple_script_wrapper.sh<BR> ++++++++++++++++++++++++++++++++<BR> <BR> ###################<BR> # ERROR HANDLING & RETURN CODES<BR> ###################<BR> # RETURN CODE: Set initial Return Code - RC for this script.<BR> RC=1<BR> echo 'RETURN CODE: Set initial Return Code - RC for this script.' >> $log _file 2>&1<BR> echo $RC >> $log_file<BR> <BR> cleanup()<BR> {<BR> echo cleaning up<BR> echo "RETURN CODE: $RC"<BR> }<BR> <BR> trap 'cleanup; exit $?' EXIT<BR> <BR> ########################<BR> # EXECUTE SCRIPT LOGIC: 1<BR> ########################<BR> typeset -i RC=`/bin/sh /tmp/export_simple_script.sh`<BR> if [[ $RC -ne 0 ]]; then<BR> exit<BR> else<BR> echo ' ' >> $log_file<BR> echo 'ORACLE EXPort SUCCEEDED!: '$RC >> $log_file 2>&1<BR> echo $RC >> $log_file<BR> echo ' ' >> $log_file<BR> fi<BR> <BR> # RETURN CODE: Show EXPort Return Code - RC: EXPort RETURN CODE.<BR> #RC=$?<BR> echo 'RETURN CODE: Show EXPort Return Code - RC: EXPort RETURN CODE.' >> $log_file 2>&1<BR> echo $RC >> $log_file<BR> <BR> <BR> <BR> <BR> ---THIS CODE WORKS EVERY TIME AND WHILE THE OUT IS ALWAYS THE CORRECT "RC ",<BR> "RC" IS NEVER PASSED CORRECTLY TO "export_simple_script_wrapper .sh"<BR> <BR> ++++++++++++++++++++++++++++++++<BR> export_simple_script.sh<BR> ++++++++++++++++++++++++++++++++<BR> ########################<BR> # EXECUTE SCRIPT LOGIC: 1<BR> ########################<BR> <BR> exp <<EOFexp >> $log_file 2>&1 \<BR> ...<BR> exit<BR> EOFexp<BR> <BR> # RETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE.<BR> RC=$?<BR> echo 'RETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE.' >> $log_file 2>&1<BR> echo $RC >> $log_file<BR> <BR> if [[ $RC -eq 1 ]]; then<BR> echo ' ' >> $log_file<BR> echo 'ORACLE EXPort FAILED!: '$RC >> $log_file 2>&1<BR> echo ' ' >> $log_file<BR> <BR> elif [[ $RC -eq 0 ]]; then<BR> echo ' ' >> $log_file<BR> echo 'ORACLE EXPort SUCCEEDED!: '$RC >> $log_file 2>&1<BR> echo ' ' >> $log_file<BR> <BR> else<BR> echo ' ' >> $log_file<BR> echo 'ORACLE EXPort Utility STOPPED! : '$RC >> $log_file 2>&1<BR> echo ' ' >> $log_file<BR> <BR> fi<BR> <BR> exit $RC<BR> <BR> <BR> <BR> <BR> ++++++++++++++++++++++++++++++++<BR> TWO EXAMPLE RUNS AND LOG OUTPUT<BR> ++++++++++++++++++++++++++++++++<BR> <BR> (#1.)<BR> ---FORCE "export_simple_script.sh" - KILL EXP PROCESS<BR> [oracle@(protected) tmp]$ sh export_simple_script_wrapper.sh<BR> /tmp/export_simple_script.sh: line 75: 30047 Killed exp USERID =system/orcl9imanager FULL=Y ...<<EOFexp<BR> exit<BR> EOFexp<BR> cleaning up<BR> RETURN CODE: 0<BR> <BR> <BR> [oracle@(protected) tmp]$ more export_simple_script_wrapper.sh.log<BR> RETURN CODE: Set initial Return Code - RC for this script.<BR> 1<BR> <BR> ORACLE EXPort SUCCEEDED!: 0<BR> 0<BR> <BR> <BR> <BR> [oracle@(protected) tmp]$ more exp.log<BR> ...<BR> . . exporting table MON_ALERT_MESSAGES 1000 rows exported<BR> . . exporting table MON _CONF<BR> RETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE.<BR> 137<BR> <BR> ORACLE EXPort Utility STOPPED!: 137<BR> <BR> <BR> <BR> <BR> (#2.)<BR> ---FORCE "export_simple_script.sh" - BAD ORACLE PASSWORD<BR> <BR> [oracle@(protected) tmp]$ sh export_simple_script_wrapper.sh<BR> cleaning up<BR> RETURN CODE: 0<BR> <BR> <BR> [oracle@(protected) tmp]$ more export_simple_script_wrapper.sh.log.SCRIPT<BR> RETURN CODE: Set initial Return Code - RC for this script.<BR> 1<BR> <BR> ORACLE EXPort SUCCEEDED!: 0<BR> 0<BR> <BR> <BR> <BR> [oracle@(protected) tmp]$ more exp.log.SCRIPT<BR> ...<BR> EXP-00004: invalid username or password<BR> EXP-00005: all allowable logon attempts failed<BR> EXP-00000: Export terminated unsuccessfully<BR> RETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE.<BR> 1<BR> <BR> ORACLE EXPort FAILED!: 1<BR> <BR> </FONT> </P>