hello people i am trying to parse a radius log with a regexp provided by
rob,the regexp used to work with a cisco cdr log and i am trying to
adapt it to parse a radius log. I am trying to get the NAS-IP-Address
parameter but i get the following output:
perl optrad.pl
Argument "IP" isn't numeric in subtraction (-) at optrad.pl line 54.
Argument "NAS" isn't numeric in subtraction (-) at optrad.pl line 54.
Argument "Address" isn't numeric in subtraction (-) at optrad.pl line 54.
Use of uninitialized value in concatenation (.) at optrad.pl line 54.
NAS-IP-Address :
I tried to scape the "-" but it did'nt work
This is the script:
#!/usr/bin/perl
my $log_entry = q[Sat Jul 27 07:07:00 2002
NAS-IP-Address =10.0.0.2
NAS-Port-Type = Async
User-Name = "5555555"
Called-Station-Id = "222222228"
Calling-Station-Id = "3333333333"
Acct-Status-Type = Stop
Service-Type = Login-User
h323-gw-id = "h323-gw-id=bue-pstngw-div1."
Cisco-AVPair = "h323-incoming-conf-id=53E0B5CC A08011D6
8D649004 9931091"
h323-call-origin = "h323-call-origin=answer"
h323-call-type = "h323-call-type=VoIP"
h323-setup-time = "h323-setup-time=*07:14:18.107 GMT Sat Jul 27
2002"
h323-connect-time = "h323-connect-time=*07:14:39.524 GMT Sat
Jul 27 2002"
h323-disconnect-time = "h323-disconnect-time=*07:15:02.198 GMT
Sat Jul 27 2002"
h323-disconnect-cause = "h323-disconnect-cause=10"
h323-remote-address = "h323-remote-address=10.0.0.1"
h323-voice-quality = "h323-voice-quality=10"
h323-conf-id = "h323-conf-id=53E0B5CC A08011D6 8D649004 9931091"
Acct-Session-Id = "0000053D"
Acct-Input-Octets = 17895 Acct-Output-Octets = 7825
Acct-Input-Packets = 453 Acct-Output-Packets = 397
Acct-Session-Time = 23 Acct-Delay-Time = 0 Client-IP-Address =
10.0.0.1 ];
# a single log entry
my %data = ();
# grab the date from the first section,
# and remove the first section all-together
$log_entry =~ s/^(.*?:.*?:\d+).*?:.*?:.*?:/Date $1,/;
# split the line my the commas
for (split /\s*,\s*/, $log_entry) {
# grab the name/value pairs and save to a hash
/^(\w+)\s*(.*)/ and $data{$1} = $2 and next; }
# grab what you need from the hash
print "DATE: $data{Date}\n"; print "NAS-IP-Address :
$data{NAS-IP-Address }\n"; # etc...
Any ideas on how to adecuate the regexp?
Thanks in advance,sorry for the long mail
Hernan
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]