Regular expression

Reply

Join Date: Jan 2005
Posts: 2
Reputation: Nihar is an unknown quantity at this point 
Solved Threads: 0
Nihar Nihar is offline Offline
Newbie Poster

Regular expression

 
0
  #1
Jan 31st, 2005
Hi there,
Does any one know a Perl regular expresson to ignore specific string from a log file.
For example i want to use this simple unix command using perl regular expression

egrep -i -n "error|fatal" logfile.log |\egrep -v "user not found"

i.e. it should ignore log file entry "Error user not found" but at the same time if log file contains "error script fails" it should detect "error".

Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Regular expression

 
0
  #2
Jan 31st, 2005
maybe post a few lines of the logfile..?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 42
Reputation: YUPAPA is an unknown quantity at this point 
Solved Threads: 0
YUPAPA's Avatar
YUPAPA YUPAPA is offline Offline
Light Poster

Re: Regular expression

 
0
  #3
Feb 6th, 2005
Originally Posted by Nihar
Hi there,
Does any one know a Perl regular expresson to ignore specific string from a log file.
For example i want to use this simple unix command using perl regular expression

egrep -i -n "error|fatal" logfile.log |\egrep -v "user not found"

i.e. it should ignore log file entry "Error user not found" but at the same time if log file contains "error script fails" it should detect "error".

Thanks in advance.
You mean this??

  1. if(/error script fails/i) {
  2. next if(/Error user not found/i);
  3. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 2
Reputation: Nihar is an unknown quantity at this point 
Solved Threads: 0
Nihar Nihar is offline Offline
Newbie Poster

Re: Regular expression

 
0
  #4
Feb 11th, 2005
here is the log file content

365:[2005-02-10 10:43:39,499][testapi][INFO ][Servlet.Engine.Transports : 252][service.BaseService] - ApplRef: null Error -NXFB=(8;701) user not found in database.
370:[2005-02-10 10:43:47,955][testapi][ERROR][Servlet.Engine.Transports : 41][OLDLOGGING] - - E - - - User does not have the
required access level for this application.

The first line should be ignored eventhough it contents sring "Error".
but the second line should raise a flag because it does not content string "user not found in database"
i believe it's clear now. I'm looking for regular expression to parse this kinda log file. i can simply use egrep and egrep-v but that's not the solution i cna use here.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1
Reputation: Schwallex is an unknown quantity at this point 
Solved Threads: 0
Schwallex Schwallex is offline Offline
Newbie Poster

Re: Regular expression

 
0
  #5
Feb 18th, 2005
How about just parsing for [ERROR]?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 42
Reputation: YUPAPA is an unknown quantity at this point 
Solved Threads: 0
YUPAPA's Avatar
YUPAPA YUPAPA is offline Offline
Light Poster

Re: Regular expression

 
0
  #6
Feb 18th, 2005
Originally Posted by Schwallex
How about just parsing for [ERROR]?
  1. if($line =~ /\[ERROR\]/) {
  2. print "It contains error\n";
  3. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC