Hernan Marcelo Salvarezza wrote at Mon, 27 May 2002 16:30:38 +0200:

> Hello all i am parsing a cisco cdr log and i am having some problems to create the 
>adecuate regexp
> 
> the log goes like this
> 
> May 16 08:03:58  10.0.0.1   38#00155544446, SetupTime 11:06:31.062 DisconnectTime 
>11:10:06.922 May
> 16 08:03:58  10.0.0.1   38#00155544446,SetupTime 11:06:31.062 DisconnectTime 
>11:10:06.922 May 17
> 08:03:58  10.0.0.1   38#00155544446, SetupTime 11:06:31.062 DisconnectTime 
>11:10:06.922 May 17
> 08:03:58  10.0.0.1   38#00155544446,SetupTime 11:06:31.062 DisconnectTime 
>11:10:06.922
> 
> 
> The script goes like this
> 
> $VOIP = 'cat logprueba.log | egrep
> --regexp=%VOIPAAA-5-VOIP_CALL_HISTORY|cut -f6 -d " "';
> 
> system('cat log1.log | egrep --regexp=PeerAddress| cut -f10 -d " "| sed -e s/38#//g >
> /var/log/parsed');
> 
> $dialednumber='sed -e s/,//g /var/log/parsed';
> 
> 
> From this script i get the dialed number,setup time and disconnect time,now i have 
>got to repeat
> this to analize the entire log,i was thinking in a foreach loop to look for a 
>repetitive
> pattern(like %VOIPAAA-5-VOIP_CALL_HISTORY) and repeat the parsing for each ocurrence 
>of the
> pattern.
> 

you can sepeare number, setup and disconnection time with the regexp:
my ($number, $setup, $disconn) = $line =~
  /(\d+\#\d+)          # the number
   (?:.*?)             # some characters, but minimal ones
   (\d\d:\d\d:\d:\d)   # the setup time
   (?:.*?)             # again some characters
   (\d\d:\d\d:\d:\d)/x; # the disconnection time

Note, that I uses (?: ...) to avoid capturing of the parts between.
Note also, that the number has to contain a # in it.

The times can be parsed with:
my ($hour, $min, $sec) = split ':', $timestr;

Hope I could help you,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to