Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: PART II: - Beyond a basic Oracle EXP/IMP shell script: Error Handling & Exit Status?

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

From: Marquez, Chris <cmarquez_at_collegeboard.org>
Date: Thu, 1 Sep 2005 17:22:24 -0400
Message-ID: <B30C2483766F9342B6AEF108833CC84E05BD5F6E@ecogenemld50.Org.Collegeboard.local>


It worked!

Only like this;

---export_simple_script_wrapper.sh
...
#typeset -i RC=`/bin/sh /tmp/export_simple_script.sh`
#typeset -i RC=`/tmp/export_simple_script.sh`
/tmp/export_simple_script.sh
RC=$?
...

---export_simple_script.sh
...
exit $RC

Seems the "typeset -i RC=...." will not work for me.

Chris

-----Original Message-----
From: Radoulov, Dimitre [mailto:cichomitiko_at_gmail.com] Sent: Thu 9/1/2005 4:58 PM
To: Marquez, Chris; oracle-l_at_freelists.org Subject: Re: PART II: - Beyond a basic Oracle EXP/IMP shell script: Error Handling & Exit Status?  

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



export_simple_script_wrapper.sh:

###################
# ERROR HANDLING & RETURN CODES
###################

export log_file="export_simple_script_wrapper.log"
# 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 /app/oracle/stagearea/export_simple_script.sh`
/app/oracle/stagearea/export_simple_script.sh RC=$?
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



export_simple_script.sh:

########################
# EXECUTE SCRIPT LOGIC: 1
########################

exp userid=test/test file=test.dmp log=test.log >> $log_file 2>&1 export RC=$?

# 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


Output & logfile:

$ ./export_simple_script_wrapper.sh
cleaning up
RETURN CODE: 1 $ vi export_simple_script_wrapper.log
"export_simple_script_wrapper.log" 19 lines, 538 characters RETURN CODE: Set initial Return Code - RC for this script. 1

Export: Release 9.0.1.5.0 - Production on Thu Sep 1 22:53:33 2005

(c) Copyright 2001 Oracle Corporation. All rights reserved.

EXP-00056: ORACLE error 1034 encountered
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory 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

HTH
Dimitre Radoulov

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Sep 01 2005 - 16:33:08 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US