Help needed to send email

Hi ,

Below is the part of Ksh.I have written.

The sql below generates list of records for undelivered letters.

## - spool undelivered letter list
cd $cs_LOG
$ORACLE_BIN/sqlplus $USER/$PASS @$cs_PROG/spool_undelivered_letters.sql

The below Ksh check for the file and send emails.

##if log file is not empty save it with the date and send email
if [ ! -s $cs_LOG/undelivered_letters.log ]; then
echo 'all letters delivered'
else
cp $cs_LOG/undelivered_letters.log $cs_LOG/undelivered_letters_age29.log.`date +%Y%m%d`
echo 'Undelivered letters check cust serv letters log directory ' `date` | /usr/bin/mailx \
-c test@yahoo.com \
-r eletters@xxx.com \
-s 'Undelivered letters' \
test@yahoo.com;
fi

But My problem is even though the spool does not contain any data it sends email.

The requirement is if undelivered_letters.log does not contain any data then we are not supposed to send the email.If it has data then we sould send email.

It seems , the undelivered_letters.log file is having some data all the time. The logic you used here to check the "filesize" is correct and i strongly suspect the content of the file undelivered_letters.log

yes . I always find the size of the undelivered_letters.log is 1k even though there is no records in it !

Ohh , in that case you need to check .sql logic to see whether you are properly spooling or not

use

sqlplus -s

to connect to the data base and use

SET options 

available with SQL*Plus to turn everything off