Shell script to send a mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to send a mail
# 1  
Old 08-25-2008
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.
# 2  
Old 08-25-2008
Ilittle bit of everything u need for database scripting:

Code:
#!/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

# 3  
Old 08-25-2008
Many Thanks for your Prompt response.
Sekar
# 4  
Old 08-25-2008
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
# 5  
Old 08-25-2008
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to send mail alert

Hi I have below shell script to send mail alert , however I want to add more functionality in this script and that is , script should only check that file between 9 am to 5pm , and if there is no activity in this time 9 am to 5 pm for 2hours then it should give me mail alert, please help... (2 Replies)
Discussion started by: scazed
2 Replies

2. UNIX for Beginners Questions & Answers

Shell script to compare text and send a mail

Hello, Somebody can help me to develop a script for the below requirement I have a 3 files in a directory which was dynamically changed everyday basis. I need a script to fetch the 1pattern of strings in each file. if the three matching pattern is same send a mail with subject as success else... (1 Reply)
Discussion started by: MATHANKUMAR
1 Replies

3. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

4. Shell Programming and Scripting

Shell script to send mail alert

HI Guys, I am writing one shell script to send the mail alert to some email id's if the file not modified in last 10 mins but its not working, I believe MTIME is null string is wrong . can you please assist me on this. script :- filename="abc.txt" echo "Filename is $filename"... (1 Reply)
Discussion started by: abhigrkist
1 Replies

5. Shell Programming and Scripting

To send a mail through shell script

I want to send a mail through shell script,If it is possible Please give me a code. mail id : upload.xxx@example.com (8 Replies)
Discussion started by: kannansoft1985
8 Replies

6. UNIX for Dummies Questions & Answers

How to send e-mail from shell script ( C shell )?

Hi , How to send e-mail from shell script ( C shell ) . Mailx command is not working ( It didn't giving error also ). Please help me (2 Replies)
Discussion started by: arukuku
2 Replies

7. Shell Programming and Scripting

Looking for shell script to monitor CPU utilization and send mail once exceed 75%

Dear Group, I'm look for shell script to Monitor CPU usage and send mail once it exceed 75% I'm running Suse10.4. (3 Replies)
Discussion started by: clfever
3 Replies

8. UNIX for Advanced & Expert Users

Send a mail when a shell script is modified

I would like to know, whether is there any command/tool in Linux (something like Oracle Trigger function) to send a mail if a particular shell script has been modified with details like, modification time, modified by, etc. Thanking in advance, (1 Reply)
Discussion started by: apsprabhu
1 Replies

9. Shell Programming and Scripting

shell script to send a mail

Hi, I need a shell script which runs in the backround for all the 24 hours and send a mail to us regarding the output of the prstat command when the load average increase above certain percent. kindly help me on this...... (1 Reply)
Discussion started by: jayaramanit
1 Replies

10. Shell Programming and Scripting

Send e-mail in Shell script

How to send an error mail from a shell script e.g. mail destination_adr@blabla.int "Message : here an error message " thanks, Ann. (1 Reply)
Discussion started by: annelisa
1 Replies
Login or Register to Ask a Question