Script for sending notification mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for sending notification mail
# 1  
Old 05-09-2013
Script for sending notification mail

hi all,
needed a script to send a notfication mail if the specified folder had the copy of the files that are older than 15 days
i.ee for example
my folder name is SAi
and the files are as follows
sai.txt
copyofsai.txt
copyofcopyofsai.txt
hemanth.txt
copyofcopyofhemanth.txt
copyofcopyofcopyofhemath.txt

if SAI folder contains the above files and if the copy files created are older than 15 days then a notification mail should ne sent to the defined user mail address specify that you have
2 copies of sai.txt and 2 copies of heamnth.txt please remove as early s possible

thanks in advance
hemanth saikumar
# 2  
Old 05-09-2013
These are the tools you need to know:
1. for loop to loop through .txt files.
2. if condition
3. find command. In particular the -mtime switch.
4. mailx utility.
# 3  
Old 05-09-2013
iam new to unix shell script could u please script it..Smilie

---------- Post updated at 05:20 AM ---------- Previous update was at 12:49 AM ----------

any idea wat to do.?
# 4  
Old 05-13-2013
hiii

hi can anyone help me on the above issue..?


regards
vasa hemanth saikumar
# 5  
Old 05-13-2013
hope this will help you

Code:
mail_subject="write the subject of the mail"
mail_ids="email id of the person"
main_body="file which contains mail body"

find . -type f -mtime +15 | cut -c3- | grep "^copy" > file.txt
no_file=`cat file.txt | wc -l`
if [ $no_file -ge 1 ]; then
        mailx -s "$mail_subject" "$mail_ids" < $mail_body
fi


Last edited by Little; 05-13-2013 at 03:01 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending Mail via shell script

I am in need of a script that will send out emails while going through a NAT. What I have that works is as follows: display_remote_IP | sort | uniq | while read i do FOUND=0 for IP in `echo $ACCEPTABLEIP` do if ; then FOUND=1... (2 Replies)
Discussion started by: ldapguy
2 Replies

2. Shell Programming and Scripting

Sending mail from shell script

Hello All, I m trying to send mail from my unix script, I have used the below command mailx -s 'hi' email address < temp.txt It is not giving me any error,but I couldn't receive the mail Can you please help me. Many Thanks, Pragyan (6 Replies)
Discussion started by: prarat
6 Replies

3. Shell Programming and Scripting

shell script not sending mail

Hi, I have shell script which checks the filesystem check but does not send the mail. I might be missing something very simple.. could you please help? #!/bin/sh _servers="machine name" _out="/tmp/output.$$" _email="me@there.com" _sub="Disk Space Report $(date)" _mail=/usr/bin/mail... (5 Replies)
Discussion started by: Pandee
5 Replies

4. Shell Programming and Scripting

check postfix deferred mail and send notification script

Hi Guys, I have a postfix server which is deferring emails. Now I need to send notification to a specific email address if: The sender of the deferred email is: abc@example.com Contains specific subjects: a file (/opt/subjects) contains all the subjects in place Then need to send a... (0 Replies)
Discussion started by: linuxrulz
0 Replies

5. AIX

Sending an email notification when syslog goes down

Hi All of a sudden the syslog daemon in the server went down and then later I started it manually # ps -ef | grep syslogd root 217228 114906 0 Nov 16 - 0:00 /usr/sbin/syslogd root 430306 290870 0 14:18:11 pts/0 0:00 grep syslogd Can some one help me with a script which will monitor the... (2 Replies)
Discussion started by: newtoaixos
2 Replies

6. UNIX for Dummies Questions & Answers

Sending a mail from unix script doubt

HI i usually send an a file attachment in a mail from unix like following. mailx -s 'Job Success' someoner@gmail.com < attachment.log But I have observed in several threads that we can also use uuencode and uudecode. What are they? when should we use uudecode and uuencode ... (1 Reply)
Discussion started by: rajesh_tns
1 Replies

7. Shell Programming and Scripting

sending a mail using shell script

Please help me in writing the script for sending an attachment through email.(For example my text file name is :abc.txt and it is in directory d:/abc) (1 Reply)
Discussion started by: anitha126
1 Replies

8. Shell Programming and Scripting

shell script needed for mail queue notification

Hi shell experts, I would like to have a shell script running in a redhat server for monitoring the mailqueue status. I have already installed the qmHandle and I am using it to get a status of the mail queue in daily basis. I am executing the qmhandle in the cron. Now I am planning to execute... (10 Replies)
Discussion started by: Nightman
10 Replies

9. HP-UX

sending mail from a script

Hi I want to send a mail (to my id like abc@xyz.com) from a shell script running on HP Ux. Would like to include text from a file or include the file as attachment, either ways. Thanks Sidhu (6 Replies)
Discussion started by: Amardeep
6 Replies

10. Shell Programming and Scripting

Sending Mail Thru Unix Script

What are all the things that should be configured in order to send a mail from Unix box. An eg. program of sending a mail will help me a lot!!!!!! Thanks in advance -Om (5 Replies)
Discussion started by: Omkumar
5 Replies
Login or Register to Ask a Question