.ora-code.com

Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
PART II: - Beyond a basic Oracle EXP/IMP shell script: Error Handling & Exit

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

2005-09-01       - By Marquez, Chris
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

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@(protected) 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@(protected) 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@(protected) 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@(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 &amp; 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>
&nbsp;- export_simple_script_wrapper.sh<BR>
&nbsp;- export_simple_script.sh<BR>
<BR>
<BR>
export_simple_script.sh seems to work every time and in the logs shows the
correct &quot;$RC&quot; (=$?) 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 &quot;if&quot; logic proves that it is always getting
success &quot;0&quot; 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 &amp; 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.' &gt;&gt; $log
_file 2&gt;&amp;1<BR>
echo $RC &gt;&gt; $log_file<BR>
<BR>
cleanup()<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo cleaning up<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;RETURN CODE: $RC&quot;<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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit<BR>
else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ' ' &gt;&gt; $log_file<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'ORACLE EXPort SUCCEEDED!: '$RC
&gt;&gt; $log_file 2&gt;&amp;1<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $RC &gt;&gt; $log_file<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ' ' &gt;&gt; $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.' &gt;&gt;
$log_file 2&gt;&amp;1<BR>
echo $RC &gt;&gt; $log_file<BR>
<BR>
<BR>
<BR>
<BR>
---THIS CODE WORKS EVERY TIME AND WHILE THE OUT IS ALWAYS THE CORRECT &quot;RC
&quot;,<BR>
&quot;RC&quot; IS NEVER PASSED CORRECTLY TO &quot;export_simple_script_wrapper
.sh&quot;<BR>
<BR>
++++++++++++++++++++++++++++++++<BR>
export_simple_script.sh<BR>
++++++++++++++++++++++++++++++++<BR>
########################<BR>
# EXECUTE SCRIPT LOGIC: 1<BR>
########################<BR>
<BR>
exp &lt;&lt;EOFexp &gt;&gt; $log_file 2&gt;&amp;1&nbsp; \<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.' &gt;&gt;
$log_file 2&gt;&amp;1<BR>
echo $RC &gt;&gt; $log_file<BR>
<BR>
if [[ $RC -eq 1 ]]; then<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ' ' &gt;&gt; $log_file<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'ORACLE EXPort FAILED!: '$RC
&gt;&gt; $log_file 2&gt;&amp;1<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ' ' &gt;&gt; $log_file<BR>
<BR>
elif [[ $RC -eq 0 ]]; then<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ' ' &gt;&gt; $log_file<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'ORACLE EXPort SUCCEEDED!: '$RC
&gt;&gt; $log_file 2&gt;&amp;1<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ' ' &gt;&gt; $log_file<BR>
<BR>
else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ' ' &gt;&gt; $log_file<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'ORACLE EXPort Utility STOPPED!
: '$RC &gt;&gt; $log_file 2&gt;&amp;1<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ' ' &gt;&gt; $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 &quot;export_simple_script.sh&quot; - KILL EXP PROCESS<BR>
[oracle@(protected) tmp]$ sh export_simple_script_wrapper.sh<BR>
/tmp/export_simple_script.sh: line 75: 30047 Killed&nbsp;&nbsp; exp USERID
=system/orcl9imanager FULL=Y ...&lt;&lt;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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; MON_ALERT_MESSAGES&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1000 rows
exported<BR>
. . exporting table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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 &quot;export_simple_script.sh&quot; - 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>

</BODY>
</HTML>