Script To Send Warning


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script To Send Warning
# 1  
Old 12-02-2010
Script To Send Warning

Hi,

I have a variable that grep's on multiple words in a log file. When a certain value is met I would like to send a warning by email. I have tested on a
log file that contains the search words however I do not receive any email.

Here is what I have:

Code:
 
STRING=$(grep 'ctx|saw|EJBException' /apps/jboss-old/server/hk/log/server.log.20101202.bak | tail -1 | wc -l)
 
if (( ${STRING} > 0 ));
 
then
 
printf "-------------------Possible Restart Of HK Jboss Required-------------------" > jboss_error_log.txt
 
cat jboss_error_log.txt | mailx -s "HK Jboss Issue Found" myemail@mycompany.com.au
 
fi

I will be running a cron job every 15 minutes

Where am I going wrong and is there is a better way to do this?

Thanks in advance
# 2  
Old 12-02-2010
To send mail I personally prefer to the following commands:
Code:
echo -e "From: sender <sender@yourcompany.com>\nSender: sender <sender@yourcompany.com>\nTo: kevintse <user@gmail.com>\nSubject: Subject goes here\n\nMain text goes here\n" | sendmail user@gmail.com

If you don't receive mails with the commands above, checkout /var/log/maillog.
P.S. Make sure sendmail is started.
# 3  
Old 12-05-2010
Turns out that I was running the the wrong grep command for the search
in the variable. This meant that the string variable would only return a value of 0 and as a result no text file was created and no email was sent when error was detected. Changed to egrep 'ctx|saw|EJBException'

kevintse - thanks for your input.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Need little script to send out email

Hi Scripters, good day. bash-4.2# df -g /apps/prd Filesystem GB blocks Free %Used Iused %Iused Mounted on /dev/xxx 64.00 4.35 94% 1269284 8% /xxx bash-4.2# I was wondering if there is a script when the usage of the mountpoint above hit 98%, email would be... (3 Replies)
Discussion started by: jaapar
3 Replies

3. Shell Programming and Scripting

How to capture exit code of child script and send it to parent script?

#!/usr/local/bin/bash set -vx /prod/HotelierLinks/palaceLink/bin/PalacefilesWait /prod/HotelierLinks/palaceLink/bin/prodEnvSetup 03212013 & if then echo "fatal error: Palace/HardRock failed!!!!" 1>&2 echo "Palace Failed" | mail -s "Link Failed at Palace/HardRock" -c... (1 Reply)
Discussion started by: aroragaurav.84
1 Replies

4. Shell Programming and Scripting

script to send mail !!

Hi Experts.. i have created a table with the fields, empid name mailid 1 raja raja@xy.com and entered the values of all persons who are in that file... i have a .csv file date shift1 shift2 6/6/2011 ram raja Now i want a script that could fetch the data in (input file .csv file) and... (3 Replies)
Discussion started by: cratercrabs
3 Replies

5. Shell Programming and Scripting

Help-send mail script

Hi, I have written one script for sending mails with attachment. currently its working for only one recipient. I want to send mails to n number of users by taking user input i.e number of users. Output of current script: Enter how many files : 1 Enter First Name : kiran E-Mail... (2 Replies)
Discussion started by: kiran_j
2 Replies

6. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

7. Shell Programming and Scripting

send an email of script output

Hi All, I'm trying to send some file which generated by script to my email. when I run the script I'm getting an email. Thats fine. But it seems to be all messed up like below Memory Status on ServerA: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!! CPU Status on ServerA:... (4 Replies)
Discussion started by: s_linux
4 Replies

8. Shell Programming and Scripting

how to send parameters to script

hi all i have a script in c-shell call test that i want to send to him parameter name of directory to go to something like this the script : cd /usr/(here i want that he will go to the name of the directory that i send to him as a parameter) like :/usr/admin admin is the parameter the... (2 Replies)
Discussion started by: naamas03
2 Replies

9. Shell Programming and Scripting

How to Send warning message to user

Hai..I have one question in unix Shell script.Following is the script System Configuration: lcpu=4 mem=8192MB kthr memory page faults cpu ----- ----------- ------------------------ ------------ ----------- r b avm fre re pi po fr sr cy ... (1 Reply)
Discussion started by: sollin
1 Replies

10. UNIX for Dummies Questions & Answers

send a page from a script

I am using the Korn shell in Solaris 2.6. Are there native functions/utilities or 3rd party shareware avaliable to page me from a shell script? If so, can you provide a sample script? (1 Reply)
Discussion started by: Ray Guido
1 Replies
Login or Register to Ask a Question