Maybe it's just me, but how can you split on commas when there are not any commas in 
$log_entry?

John Pitchko
Data Services
Saskatchewan Government Insurance

>>> Hernan <[EMAIL PROTECTED]> 08/15/02 10:01am >>>
John,everyone:
            I am sorry if the post was'nt clear enough,this is the 
script i am using now:
            and below there is a piece of the log file " julyend"

#!/usr/bin/perl -w

open(INFO1, "julyend") or die "unable to open logfile:$!\n";
while ( my $log_entry = ) {
chomp($log_entry);

# get rid of the newline
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; }

# ...do stuff here

print "$data{Date 
},$data{PeerAddress},$data{DisconnectTime},$data{ConnectTime}\n";
print "PeerAddress: $data{PeerAddress}\n"; # etc. } close INFO1;

The log extract:

Jul 1 15:21:17 10.0.0.1 265: 1w5d: %VOIPAAA-5-VOIP_CALL_HISTORY: 
CallLegType 2, ConnectionId 34AB8258 8C5711D6 8234D7A5 33676AFF, 
SetupTime .18:28:42.780 UTC Mon Jul 1 2002, PeerAddress 0015454512, 
PeerSubAddress , DisconnectCause 11 , DisconnectText user busy., 
ConnectTime .18:28:43.530 UTC Mon Jul 1 2002, DisconnectTime 
...18:28:43.530 UTC Mon Jul 1 2002, CallOrigin 1, ChargedUnits 0, InfoType 
2, TransmitPackets 0, TransmitBytes 0, ReceivePackets 0, ReceiveBytes 0

Try it out and you'll see that i extract the parameters that i 
need,telephone number(PeerAddress),disconnect time and connect time.

The modified script is the following:
#!/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";...

So which line is 54?(there might be a few spaces that got lost when i 
copied the script)
The line 54 of the script is:  print "NAS-IP-Address : 
$data{NAS-IP-Address }\n";
The errors that i get are related to the ¨-" signs in 
NAS-IP-Address...(I think)

The problem is that i need it to parse  the radius log and also get the 
telephone number,disconnect time connect time and a i can' nt get  the 
regexp to work properly ,after extracting  the lines that containts the 
mentioned parameters i need to  print them out to stdout or  to a file,



Thanks again
Hernan



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

Reply via email to