Shell script to send a mail

Hi ,

I need to prepare a script which will check my database with specific to particluar table. If the row count exceeds a certain limit, i need to send a mail to a set of Recipients.

Being new to unix, please guide me to complete this task.

Advance thanks,
Sekar.

Ilittle bit of everything u need for database scripting:

#!/usr/bin/ksh

countTable ()
{
sqlplus -s ${user}@${connection} << EOF
set ${setOptions}
select trim(count(*)) from ${table_name};
exit
EOF
}

user='youruser'
sid="yourSID"
domain="yourDOMAIN"
connection="${sid}.${domain}"

table_name="TEMPORAL.TEMPORAL_KK"

limit=your_LIMIT_NUMBER

setOptions="pagesize 0 pause off feedback off heading off" 

cont=$(countTable)


if [ $(echo ${cont}|grep -c "[0-9]\{${#cont}\}") -eq 0 ]
then
   echo "Not a valid number"
   exit 5
fi


if (( cont > limit ))
then
   echo "Number of reg. is ${cont}."| mailx -s "${table_name} limit exceed" your_mail@example.com
fi

exit 0

Many Thanks for your Prompt response.
Sekar

Hi,
from the below script, i need to provide both username and password along with the script. Is there any way to hide my password?

Many Thanks

Using OPS$ users (externally identified) or a file to store the passwords with the proper permissions to avoid inadequate access are the only ways i know.

There is plenty of information in the net.

Regards.