1. I want to send mail to my yahoo account as soon as my script or job executed in unix ? I saw unix mail and mailx command which sent mail in unix user. I want to send electronics mail to my account.
Can any body giude me ?
2. Is there any way if in my shell script I am executing many oracle command one by one , I want to send mail when error occurs in job only.
You can use a ksh script similar to the one below. Just make sure that you include "WHENEVER SQLERROR EXIT SQL.SQLCODE" as one of the first few lines of your SQL script. This will ensure that you get a non-zero status when an error occurs.
exec > $logfile 2>&1
sqlplus -s username/password@db @doit.sql
if (( $res != 0 )) ; then
___mailx -s "the subject" myEmail@excite.com < $logfile
====end of doit.ksh====
WHENEVER SQLERROR EXIT SQL.SQLCODE
select count(*) from dba_objects
====end of doit.sql=====
Here is an example. I have a script that looks for a certain kind of db lock. A sql script finds the locks and creates another sql script to kill them. The information is e-mailed to me. The following is the shell script:
# Check the export log for errors
for logs in `ls -t /usr04/exports/$ORACLE_SID/log | head -1`
grep "ORA-" $logs > $ERRFILE
if [ -s $ERRFILE ]
mailx -s "Export Errors for database $ORACLE_SID" dbadmin < $ERRFILE
mailx -s "No export errors today for database $ORACLE_SID" dbadmin < /dev/null