How to Send email after script runs [message #671800] |
Wed, 19 September 2018 15:54 |
|
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
|
|
|
|
|