Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: PART II: - Beyond a basic Oracle EXP/IMP shell script: Error Handling & Exit Status?
Guys, I'm stuck?
I have two scripts;
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.
Thanks in advance,
Chris Marquez
Oracle DBA
++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++# ERROR HANDLING & RETURN CODES
###################
cleanup()
{
echo cleaning up echo "RETURN CODE: $RC"
trap 'cleanup; exit $?' EXIT
########################
# EXECUTE SCRIPT LOGIC: 1
########################
typeset -i RC=`/bin/sh /tmp/export_simple_script.sh`
if [[ $RC -ne 0 ]]; then
exit
else
echo ' ' >> $log_file echo 'ORACLE EXPort SUCCEEDED!: '$RC >> $log_file 2>&1 echo $RC >> $log_file echo ' ' >> $log_file
# RETURN CODE: Show EXPort Return Code - RC: EXPort RETURN CODE.
#RC=$?
echo 'RETURN CODE: Show EXPort Return Code - RC: EXPort RETURN CODE.' >> $log_file 2>&1
echo $RC >> $log_file
---THIS CODE WORKS EVERY TIME AND WHILE THE OUT IS ALWAYS THE CORRECT "RC", "RC" IS NEVER PASSED CORRECTLY TO "export_simple_script_wrapper.sh"
++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++# EXECUTE SCRIPT LOGIC: 1
########################
exp <<EOFexp >> $log_file 2>&1 \
...
exit
EOFexp
# RETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE.
RC=$?
echo 'RETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE.' >> $log_file 2>&1
echo $RC >> $log_file
if [[ $RC -eq 1 ]]; then
echo ' ' >> $log_file echo 'ORACLE EXPort FAILED!: '$RC >> $log_file 2>&1 echo ' ' >> $log_file elif [[ $RC -eq 0 ]]; then echo ' ' >> $log_file echo 'ORACLE EXPort SUCCEEDED!: '$RC >> $log_file 2>&1 echo ' ' >> $log_file else echo ' ' >> $log_file echo 'ORACLE EXPort Utility STOPPED!: '$RC >> $log_file 2>&1 echo ' ' >> $log_file
fi
exit $RC
++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++
(#1.)
---FORCE "export_simple_script.sh" - KILL EXP PROCESS
[oracle_at_www tmp]$ sh export_simple_script_wrapper.sh
/tmp/export_simple_script.sh: line 75: 30047 Killed exp USERID=system/orcl9imanager FULL=Y ...<<EOFexp
exit
EOFexp
cleaning up
RETURN CODE: 0
[oracle_at_www tmp]$ more export_simple_script_wrapper.sh.log
RETURN CODE: Set initial Return Code - RC for this script.
1
ORACLE EXPort SUCCEEDED!: 0
0
[oracle_at_www tmp]$ more exp.log
... . . exporting table MON_ALERT_MESSAGES 1000 rows exported . . exporting table MON_CONFRETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE. 137
ORACLE EXPort Utility STOPPED!: 137
(#2.)
---FORCE "export_simple_script.sh" - BAD ORACLE PASSWORD
[oracle_at_www tmp]$ sh export_simple_script_wrapper.sh
cleaning up
RETURN CODE: 0
[oracle_at_www 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_at_www tmp]$ more exp.log.SCRIPT
...
EXP-00004: invalid username or password EXP-00005: all allowable logon attempts failed EXP-00000: Export terminated unsuccessfullyRETURN CODE: Set next Return Code - RC: ORACLE EXP RETURN CODE. 1
ORACLE EXPort FAILED!: 1
-- http://www.freelists.org/webpage/oracle-lReceived on Thu Sep 01 2005 - 09:44:42 CDT
![]() |
![]() |