The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
exiting from script arghya_owen Shell Programming and Scripting 1 06-02-2008 06:36 AM
Exiting from script when error occurs Sreejith_VK Shell Programming and Scripting 4 04-25-2008 03:53 AM
PHP5 Script 'Freeze' before exiting Unbeliever Shell Programming and Scripting 4 05-10-2007 11:32 AM
Shell script not exiting Gracefully smithK Shell Programming and Scripting 5 02-08-2007 06:48 PM
exiting in c ruffenator High Level Programming 3 04-28-2002 02:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-11-2007
lesstjm lesstjm is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 59
Script Not Exiting???

I have a shell script that runs an Oracle Export and compresses the export dump file as it is processing to a pipe.

It runs fine except I tested how it worked when the database is down. The script seemed to work correctly . It identified that the database was down and sent out an email but for some reason the process did not exit out. It is still out there. Eventhough I have a return 1 after the email is sent.

Does anyone know why this is happening. On am on Solaris using KSH. Here is my script:

# variable declaration
. /export/home/oracle/.MYenv


LOGDIR=/xxxx

# log of this script
typeset shlog
shlog=${LOGDIR}/export_full_${ORACLE_SID}.$$.log
touch ${shlog}
print "starting `date` ${0} ${@}" >>${shlog} 2>&1

print "Move old exports to proper directories" >>${shlog} 2>&1

exp_arch[1]=${EXPDIR}

DMPFILE=${EXPDIR}/exp_full_${ORACLE_SID}.`date +"%Y%m%d"`.dmp
LOGFILE=${LOGDIR}/exp_full_${ORACLE_SID}.`date +"%Y%m%d"`.log

# delete old files
rm -f ${EXPDIR}/*pipe*
rm -f ${DMPFILE} ${DMPFILE}.Z ${LOGFILE}

#pipe name
mknod ${EXPDIR}/${SOURCE}fcompress p
chmod 644 ${EXPDIR}/${SOURCE}fcompress

print "Start Compress Pipe" >> ${shlog}
compress < ${EXPDIR}/${SOURCE}fcompress > ${DMPFILE}.Z &
TMPDIR=/xxxxx
errorfile=${TMPDIR}/errcheckf$$.${ORACLE_SID}
touch ${errorfile}


print "Begin Export\n" >> ${shlog}
export ORACLE_SID=${ORACLE_SID}
$ORACLE_HOME/bin/exp userid=${xxxx}/${xxx} file=${EXPDIR}/${SOURCE}fcompress log=${LOGFILE} DIRECT=Y FULL=Y >>${shlog} 2>&1

# check for export errors
cat ${LOGFILE} | grep EXP-000 | grep -v EXP-00067 >> ${errorfile}
bkpemail=xxxxx@us.hsbc.com
if [ -s "${errorfile}" ]
then
print "\nError in full export of ${ORACLE_SID} database!\n" >> ${shlog}
print "Ending program ${@} `date` ${0}." >>${shlog} 2>&1
mailx -s "(${ORACLE_SID}) Full Database Export Error" ${bkpemail} < ${shlog}
cat ${shlog}
return 1
fi

print "Export was Successful!" >> ${shlog}

rm -f ${errorfile}
rm -f ${EXPDIR}/*fcompress*

print "Cleanup log files\n" >> ${shlog}

#clean up files

find ${LOGDIR}/export_full_${ORACLE_SID}*.log -type f -mtime +7 -print | xargs rm -f
find ${LOGDIR}/exp_full_${ORACLE_SID}*.log -type f -mtime +7 -print | xargs rm -f

print "Ending program ${@} `date`${0}." >>${shlog} 2>&1


return 0
  #2 (permalink)  
Old 07-11-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
I think this behavior is due to the exp command which, if oracle is down, enters in interactive mode and asks the user for username/password without exiting immediately (but I tested it quickly, maybe there's another reason).

However, I recommend you to test if oracle is down *before* you try to invoke the export command. Just add these simple lines:

Code:
sqlplus -s ${xxxx}/${xxx} <<EOF >/dev/null 2>&1
whenever oserror exit 98;
whenever oserror exit 99;
exit 140;
EOF

if [ "$?" -ne 140 ]
then
   echo "Oracle is down!"
fi
Bye
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0