Home » Infrastructure » Unix » How to Send email after script runs (Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production)
How to Send email after script runs [message #671800] Wed, 19 September 2018 15:54 Go to previous message
vharish006
Messages: 70
Registered: August 2015
Location: Chicago
Member
Hi All,

I have written below script which will take csv files and load them in to tables. But how can I send an email to my inbox after the program completed successfully or not. I saw the "Mailx" command but not sure how to pick it exactly.

Please suggest

SQL_LOGIN=$1
USER_ID=$2
APPS_LOGIN=$3
REQ_ID=$4
SCHEMA=$5
date=`date +\%Y\%m\%d_%H\%M\%S`

if [ $5 = 'EBSPRD' ]
then
##EBS PRD##
targetdir="##################"
archivedir="######################"
else
##Non-Prod Instances##
targetdir="################"
archivedir="################"
fi

outfile="$XXPQ_TOP/out/"$APPS_LOGIN.$REQ_ID

echo "+---------------------------------------------------------------------------+"
echo
echo "REQ_ID :" $REQ_ID
echo "Setting directory paths and variables...."
echo "targetdir :"$targetdir
echo "date :"$date
echo "archivedir :"$archivedir
echo
echo "+---------------------------------------------------------------------------+"


cd $targetdir
#--------------------------------------------------------
#Open Loop to process Ringgold Files
#---------------------------------------------------------
for i in $(cat Control_file_list.txt)
do
#----------------------------------------------------
# SQL*LOADS Ringgold Data
#----------------------------------------------------  
echo $i

logfile="$XXPQ_TOP/log/"$i"_"$date.log

echo "SQL*Loading Ringgold data ..."
sqlldr userid=$SQL_LOGIN control=$i.ctl \
                                 log=$logfile \
                                    
                             

if [ "$?" -ne 0 ]; then
error_message="Error: SQL*Loader Failed"
cat $logfile >> $outfile 
echo $error_message
exit 1
else
cat $logfile >> $outfile
echo "Files Moving to Archive Folder" 
mv  $i.csv  $archivedir
echo "SQL* Loader Program Sucessfully"
fi
echo "+---------------------------------------------------------------------------+"


done

exit 0

 
Read Message
Read Message
Read Message
Previous Topic: Oracle installation vs OS (Unix, Windows, Solaris etc).
Next Topic: solaris script for running sql statement
Goto Forum:
  


Current Time: Fri Apr 26 02:52:09 CDT 2024