Capture all error message in Log file and send the Log file by email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture all error message in Log file and send the Log file by email
# 1  
Old 04-30-2011
Capture all error message in Log file and send the Log file by email

Hi
I have a requirement to write a script to capture all errors in a Logfile and send the file in email.
If there is any error occurred the subject of email will be ERROR , If there are no error occurred the subject of email will be SUCCESS.

So I created a Log file and put the Appropriate message to Logfile.
I check $? !=0 then I write "**ERROR** happened in this task" to Log file.

At the end of the script I do
Quote:
Error_Count=`grep **ERROR** Logfile | wc -l`
But I get Null in $Error_Count. So I am not able determine how to know if there are any ERROR.
But when I open the Logfile after the script finishes I see **ERROR** present in Logfile. Can anyone suggest me how to capture all error message and send in Logfile.

Thanks and Regards
Digambar
# 2  
Old 05-01-2011
I guess * is expanded .. try below:
Code:
grep '\*\*ERROR\*\*' LogFile | wc -l

Also try same command on command line to see what you get ...
with newer grep it will show you what is matched in different colour .

grep --color=auto
# 3  
Old 05-01-2011
Hi Chakrapani
Thanks for your reply, Do you think the grep will work even if it is buffer. Because the script is wrtiing to Logfile and I will be checking the same Logfile in the script. Even if for me ** is not imporant. But wanted to search by a pattern to find if there a error in Logfile.
Do you think the way I am doing is ok or is there a better way to capture all the errors.


Thanks
Dgmm
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send an email if "No such file or directory" in the shell script program log in EBS concur

Hi All, I have the below code(.sh) and need to send an email. #!/bin/bash cp /u02/xxc_incoming/TEST*.dat /u02/xxc_archive_incoming/AMER7764_ARPP_2/ cat /u02/xxc_incoming/TEST*.dat > /u02/xxc_incoming/XXC_TEST.dat rm /u02/xxc_incoming/TEST*.dat cd $XXC_TOP/bin sqlldr userid=apps/<pwd> ... (12 Replies)
Discussion started by: Mist123
12 Replies

2. Shell Programming and Scripting

help with email to be triggered based on fatal error detection from batch run log file neded

Hi, I require need help in two aspects actually: 1) Fatal error that gets generated as %F% from a log file say ABClog.dat to trigger a mail. At present I manually grep the log file as <grep %F% ABClog.dat| cut-d "%" -f1>. The idea is to use this same logic to grep the log file which is... (1 Reply)
Discussion started by: zico1986
1 Replies

3. Shell Programming and Scripting

format log file and send in email.

Hi guys i have one script which is as below do some sqlplus output in to $LOG sed '/^$/d' $LOG > /tmp/job.log mv /tmp/job.log $LOG awk '{if ($5=="COMPLETED") {print "backup completed at "$3" "$4 " of " $6 " for " d>> "/home/email.log" } else {print "check backup for " d}}' d="$ORACLE_SID"... (2 Replies)
Discussion started by: tapia
2 Replies

4. Shell Programming and Scripting

How to capture output to log file

Hi I have a script that will run multiple unix & sql commands. I want to see the output as well as capture it to a log file for further analysis. Is there an easy way to do that instead of adding "tee -a logfile" on everyline or even on the execute line (i.e. script | tee -s logfile). Thanks (1 Reply)
Discussion started by: nimo
1 Replies

5. Shell Programming and Scripting

Send-file /var/log/message

Hello All i need Shell Script to send /var/log/message or another if he have or grep this file to have some info like PID or value (e.g like NFS mount - stop ) to some body in my System Thanks for Advanced (2 Replies)
Discussion started by: Hosam
2 Replies

6. Shell Programming and Scripting

how to send contents of a file to email as a message

i have a file new1.txt i want to send the contents of that file as a message to email ali@sms.com i m using ksh script......... plz help me (5 Replies)
Discussion started by: ali560045
5 Replies

7. Shell Programming and Scripting

error-when trying to send the message thru email.

Hi All, I want to send a message through email. I have written below code. But it is not worling. Anybody has idea, why it is not working?. export $file1=$home1/pip1.$$ mailx -s "This Message from unix" abc@yahoo.com< $file1 thanks,Mary. (5 Replies)
Discussion started by: MARY76
5 Replies

8. Shell Programming and Scripting

Fishing out error message within a log file

Hi all, i have a log file that captures success or failure messges when i run a daily job. here is a sample of my log. 20060312 start successful successful failure failure 20060312 end i need to write a subroutine that opens up the log daily after my job completes to examine the log... (2 Replies)
Discussion started by: new2ss
2 Replies

9. Shell Programming and Scripting

capture nohup log file

Hi, I am running my script using nohup, but I am not able to capture the log file for that process could naybody please help... Here is what I am doing.... nohup ./script & 1>/home/user1/log.txt but I am not able to capture the log.....Is there anyother way I can capture the log... (2 Replies)
Discussion started by: mgirinath
2 Replies

10. Shell Programming and Scripting

Sh Prgram to capture Log message.

Hi All, I have a log file which consists of log messages as follows -> GLOBALCALLID_CLUSTERID_B NEXT * , O(") CHARACTER JOINONBEHALFOF NEXT * , O(") CHARACTER Record 1: Rejected - Error on table IFA_MMV_CDR, column CDRRECORDTYPE.... (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question