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 next 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

Re: How to Send email after script runs [message #671801 is a reply to message #671800] Wed, 19 September 2018 17:29 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
man mailx

What should be Subject of this email?
What should be the body of this email?

http://lmgtfy.com/?q=how+to+send+email+using+mailx
Re: How to Send email after script runs [message #671802 is a reply to message #671800] Thu, 20 September 2018 00:35 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

This question bears no real connection with Oracle database.
Please find a more appropriate forum.
The topic is locked. /forum/fa/448/0/
If I'm wrong, please, PM me (or report this message to a moderator, explain why you think it should be unlocked and it might be done).

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


Current Time: Thu Mar 28 11:21:56 CDT 2024