The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk script required for finding records in 1 file with corresponding another file. RRVARMA Shell Programming and Scripting 2 07-18-2008 12:20 PM
Shell Script --- Delete ORA error from data file sk005 UNIX for Dummies Questions & Answers 1 09-25-2007 05:26 PM
Shell script to append a time for the existing error log file gsprasanna UNIX for Advanced & Expert Users 12 07-12-2007 05:07 AM
Finding error code nitinkgoud SUN Solaris 2 07-15-2006 12:43 PM
Error while creating .tar file using script Rakesh Bhat Shell Programming and Scripting 1 12-30-2005 01:40 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-17-2008
himvat himvat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 68
Smile script for finding an error from a log file

Hi ,

I have a doubt about a shell script to find an ERROR from the log file. But I need to specify a the scan from a particular date and time in the log. Till now I have developed the following script. Please suggest what shall I add in this for date and time. If the script finds a particular error it should throw 1 or else 0.


#!/bin/sh
# Script to find the error in the log file
ERROR="SCHD0061E"
read ERROR
if [ $ERROR="SCHD0061E" ] ;then
echo "1";
else echo "0"
fi

Kindly suggest what else is missing from this script. And how to specify the path for the log file .

Thanks & Regards


Last edited by himvat; 11-17-2008 at 03:25 PM..
  #2 (permalink)  
Old 11-17-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 592
Post a sample log file
  #3 (permalink)  
Old 11-17-2008
himvat himvat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 68
Kindly have a look at the sample of the log and suggest

Regards

Last edited by himvat; 11-17-2008 at 03:23 PM..
  #4 (permalink)  
Old 11-17-2008
sriharsha_kvr sriharsha_kvr is offline
Registered User
  
 

Join Date: Nov 2008
Location: Bangalore
Posts: 11
Talking

Just have a look at below code. I assume that the Errors are logged in log.txt

grep -w "ERROR" log.txt | cut -d" " -f1,2,3 > ErrLog.txt

if [ -s ErrLog.txt ]
then
echo "Has Errors"
else
echo "No Errors"
fi
  #5 (permalink)  
Old 11-17-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Question

You posted the error file as a Word document. Is it truly a Word document?
Can you simply cut/paste a section of the log into your response. Make sure to use th Code Tag. [Highlight the section of your message, then press the # icon button -- this will maintain formatting and spacing.]

Finally, if I understand you request, you are try to search from a particular data & time forward only. Please verify on this.
  #6 (permalink)  
Old 11-17-2008
himvat himvat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 68
yes I need to develop a script that will look for an error only in the current date logs and will throw an alert mail to the mail ID

thanks

Last edited by himvat; 11-17-2008 at 03:23 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0