Not able to drop single mail transfer for different conditions.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Not able to drop single mail transfer for different conditions.
# 1  
Old 03-12-2013
Not able to drop single mail transfer for different conditions.

Code:
. /apps01/wls01/Oracle/Middleware/user_projects/domains/soadomain/bin/setDomainEnv.sh > /dev/null
cd /apps01/wls01/Oracle/Middleware/wlserver_10.3/common/bin
java weblogic.WLST ServerStatus.py > a.log
TEST=`cat a.log | grep WARN | wc -l`
if [ $TEST != 0 ]; then
        `grep "WARN" a.log > 1.txt`
     mail -s "$TEST ServersWarningMode`hostname`"  xyz.mail.com < 1.txt
fi
A=soa_server1
B=bam_server1
c=AdminServer
TEST1=`cat a.log | grep soa_server1 | wc -l`
TEST2=`cat a.log | grep bam_server1 | wc -l`
TEST3=`cat a.log | grep AdminServer | wc -l`
if [ $TEST1 = 0 ]; then
        `grep "soa_server1" a.log > 1.txt`
mail -s "$A is down, please check `hostname`" abc.mail.com
fi
if [ $TEST2 = 0 ]; then
        `grep "bam_server1" a.log > 2.txt`
mail -s "$B is down, please check `hostname`" abc.mail.com
fi
if [ $TEST3 = 0 ]; then
        `grep "AdminServer" a.log > 3.txt`
mail -s "$C is down, please check `hostname`" abc.mail.com
fi


Here i need the condition like if Two servers are down then only one mail is triggered not 2 mails. Whatever the no of servers are down, it should trigger only one mail.

Moderator's Comments:
Mod Comment Use code tags!
# 2  
Old 03-12-2013
Code:
> mail_body
for server in soa_server1 nbam_server1 AdminServer
do
        if ! grep "$server" a.log > /dev/null
        then
                printf "$server is down, please check $( hostname )\n"
        fi
done > mail_body

[[ -s mail_body ]] && mail -s "Servers Down" abc.mail.com < mail_body

Login or Register to Ask a Question

Previous Thread | Next Thread

9 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. UNIX for Dummies Questions & Answers

Find and replace single character w/awk given conditions

I have a file that looks like this: 14985 DPN verb PPa to spend. 12886 DPNDJN bay tree. 15686 DQ verb to observe 15656 KC ... (7 Replies)
Discussion started by: jvoot
7 Replies

3. UNIX for Dummies Questions & Answers

Sftp transfer doing as single row

Hi All, I have a file in windows when I transfer it using sftp it is getting as single line. I tried to do both ascii and binary File: is transfered as Can you please let me know how can do the transfer as same as XML file Thanks, Arun (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

4. Shell Programming and Scripting

Errors in if conditions with to many OR conditions

Hi ALL I have a script where in i need to check for several values in if conditons but when i execute the script it throws error such as "TOO MANY ARGUMENTS" if then msg="BM VAR Issue :: bmaRequestVAR=$bmaRequestVAR , nltBMVAR=$nltBMVAR , bmaResponseVAR=$bmaResponseVAR ,... (10 Replies)
Discussion started by: nikhil jain
10 Replies

5. UNIX for Dummies Questions & Answers

Minimal Mail Server Setup for Local Mail Transfer

I am trying to get stored mail out of an old mail client. I figured that the easiest way to do it is with IMAP by logging in with both clients. I can copy the mail to the server from the old mail client, and back down into the new mail client. Rather than using a real mail account on the... (2 Replies)
Discussion started by: nixie
2 Replies

6. Shell Programming and Scripting

How to Evaluate two conditions in single if statement

I am trying to test two conditions in a single if and getting syntax error on -a and && if ] ; then echo "variable a equals to variable b" else echo "variable a not equal to variable b" fi in second attempt I used -a instead of &&, referring to other website, but not sure that... (1 Reply)
Discussion started by: praxis1
1 Replies

7. Linux

Mail drops into spam box of yahoo from a single domain

The mails are reaching from all my domains (hosted in same server) to yahoo properly when tested. But all the mails from a particular domain out of many domains hosted in the server sent to yahoo reaches yahoo's spam box. The host says that this problem is nothing to do with them since it works... (0 Replies)
Discussion started by: lampscholar
0 Replies

8. Linux

mail transfer

Hi all! How do I transfer mail already stored in /var/spool/mail/xxx to another host ? (without using ftp, rcp or any other kind of copy/archiving utility :) I'm using linux/sendmail Any idea would be greatly appreciated!!! (3 Replies)
Discussion started by: andryk
3 Replies

9. UNIX for Dummies Questions & Answers

Loggin mail transfer

Hi Folks, I'm trying to log incoming and outgoing messages on my Solaris box. I thought I could use 'mail.info /var/log/maillog' in my syslog.conf but it doesn't give any output. mail.debug does but only seems to log client connections to the server and the odd message ID. Is there a way... (4 Replies)
Discussion started by: Ben
4 Replies
Login or Register to Ask a Question