Restrict the mail upon first failure mail.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Restrict the mail upon first failure mail.
# 1  
Old 09-23-2010
Restrict the mail upon first failure mail.

Hi,
I have a application which send mail to the respective client upon success or failure case of file transfer, upon success there is no problem.
But in case of failure that application is running again in cron job,so still success of file transfer the client will get the failure notification. If it happen in weekend there is a big disaster in client mail boxSmilie

So can it possible to restrict the multiple failure mail send to the client , i mean after 2 failure mail it won't send any notification or such idea be helpful for me.


Thanks
Posix
# 2  
Old 09-23-2010
I think something may be wrong in your script. Can you post the part that does email?
# 3  
Old 09-23-2010
Hi Jim,
As the application is just a ELF package, so i can not able to dig it and there may be some case connectivity like session out,traffic or may be server down .
In this case we are using some option to get to know failure case and in script calling the application with that option and using mailx upon failure.

.sh script is in cron say every 30min . So in this case it send 40-50mail for the same failure each time.
# 4  
Old 09-23-2010
What does the crontab look like? I can gues if you'd like, but it won't help you at all.
# 5  
Old 09-23-2010
i believe crontab is working fine for me, but need to restrict the mail upon 1st failure case.
Is there any logic we can implement for this scenario ??
# 6  
Old 09-28-2010
You didn't provide any further documentation of your script (or whatever it is you execute from cron), so can give you only a sketch of a solution. It implies that the (fictitous) program "do_file_transfer" returns 0 (success) or 1 (failure) and there is a (fictitous) program "mail_to_customer", which handles the mail:

Code:
#!/bin/ksh

typeset chAddress=""
typeset fErrlog="/your/list/with/addresses.errors"
cat /your/list/with/addresses | while read chAddress ; do
     if [ $(grep -c "$chAddress" "$fErrlog") -le 2 ] ; then
          do_file_transfer $chAddress
          if [ $? -gt 0 ] ; then
               print - "$chAddress" >> "$fErrlog"
               mail_to_customer "$chAddress" "Sorry, your file transfer failed."
          fi
     fi
done

exit 0

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. Shell Programming and Scripting

rsync with e-mail notification failure

dear all, i have script rsync like this : #!/bin/sh RSYNC=/usr/bin/rsync SSH=/usr/bin/ssh RUSER=root RHOST=123.123.123.1 INTRPATH=/home/jargo/log/internasional/ INTHPATH=/var/www/international/ IIXRPATH=/home/jargo/log/iix/ IIXHPATH=/var/www/iix/ TTLRPATH=/home/jargo/log/total/... (2 Replies)
Discussion started by: indracyd
2 Replies

3. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

4. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

5. Linux

Restrict mail from Sendmail

Hello All, i have configured sendmail and trying to set a limit on mail Ex: If i have send any mail to a email-if that doesn'e exists, i want that after trying for 3 days it should stops sending that mail to user and send a mail to the sender that " sending mail failed , any messaged... (1 Reply)
Discussion started by: saurabh84g
1 Replies

6. UNIX for Dummies Questions & Answers

Mail on a box failure : Autosys

I need to send invoke a script that sends out a mail, whenever a box fails (i.e., one or more of the jobs in the box fail). The key point is that this job should start on failure of box, but it should be able to find out the jobs in the box that have failed and pass them to the script. Please... (1 Reply)
Discussion started by: hidnana
1 Replies

7. Solaris

Failure of sending mail through sun solaris

Hi , I tried to mail from my sun solaris 5.8 by: $mailx -v sridha_151086@yahoo.co.in Subject: Test mail This is the test mail!! . EOT The error message I got is: land% Sri... forward: /export/home/Sri/.forward.+: World writable directory Sri... forward:... (7 Replies)
Discussion started by: sridharnr
7 Replies

8. Shell Programming and Scripting

Failure of sending mail through sun solaris

Hi Friends, I tried to mail from my sun solaris 5.8 by: $mailx -v sridha_151086@yahoo.co.in Subject: Test mail This is the test mail!! . EOT The error message I got is: land% Sri... forward: /export/home/Sri/.forward.+: World writable directory Sri... forward:... (1 Reply)
Discussion started by: sridharnr
1 Replies

9. Solaris

how to forward mail in /var/mail/username to external mail

Dear All, Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do? thank u in advance (2 Replies)
Discussion started by: unitipon
2 Replies

10. UNIX for Dummies Questions & Answers

mail problem (NOT Mail or Mail.app)

When I try to use the CLI mail, I get the following error. What's wrong? Welcome to Darwin! % mail root Subject: test test . EOT % /etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory Do I just need to change the... (1 Reply)
Discussion started by: chenly
1 Replies
Login or Register to Ask a Question