Go to the FreeLists Home Page Home Signup Help Login
 



[oracle-l] || [Date Prev] [09-2005 Date Index] [Date Next] || [Thread Prev] [09-2005 Thread Index] [Thread Next]

RE: PART II: - Beyond a basic Oracle EXP/IMP shell script: Error Handling & Exit Status?

  • From: "Marquez, Chris" <cmarquez@xxxxxxxxxxxxxxxx>
  • To: "Reidy, Ron" <Ron.Reidy@xxxxxxxxxxxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 1 Sep 2005 10:40:34 -0400
Guys, I'm stuck?

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.

Thanks in advance,

Chris Marquez
Oracle DBA


++++++++++++++++++++++++++++++++
export_simple_script_wrapper.sh
++++++++++++++++++++++++++++++++

###################
# ERROR HANDLING & RETURN CODES
###################
# RETURN CODE: Set initial Return Code - RC for this script.
RC=1
echo 'RETURN CODE: Set initial Return Code - RC for this script.' >> $log_file 
2>&1
echo $RC >> $log_file

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
fi

# 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"

++++++++++++++++++++++++++++++++
export_simple_script.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




++++++++++++++++++++++++++++++++
TWO EXAMPLE RUNS AND LOG OUTPUT
++++++++++++++++++++++++++++++++

(#1.)
---FORCE "export_simple_script.sh" - KILL EXP PROCESS
[oracle@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@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@www tmp]$ more exp.log
...
. . exporting table             MON_ALERT_MESSAGES       1000 rows exported
. . exporting table                       MON_CONF
RETURN 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@www tmp]$ sh export_simple_script_wrapper.sh
cleaning up
RETURN CODE: 0


[oracle@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@www 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





[ Home | Signup | Help | Login | Archives | Lists ]

All trademarks and copyrights within the FreeLists archives are owned by their respective owners.
Everything else ©2007 Avenir Technologies, LLC.