#!/usr/bin/perl use strict; use DBI; open(LOG, "<20060620.act"); while (){ chomp; my @values = split(',',$_); s/^"&"$/ $_ /g; my $dbh = DBI->connect ('dbi:mysql:radius', 'radiususr', 'radiuspass') || die "Database connection not made! $DBI::errstr"; foreach my $value(@values){ if($value =~ 'Stop'){ my $sql = "insert into acct1(date, time, RAS_CLIENT, Called_Station_Id, Calling_Station_Id, Acct_Input_Octets, Acct_Output_Octets, Acct_Session_Time, Acct_Input_Packets, Acct_Output_Packets, Acct_Termination_Cause) values(@values[0], @values[1], @values[2], @values[28], @values[29], @values[34], @values[35], @values[38], @values[39], @values[40], @values[41], @values[42])"; my $sth = $dbh->prepare($sql); $sth->bind_param(1,$_->[0]); $sth->bind_param(2,$_ ->[1]); $sth->bind_param(3,$_ ->[2]); $sth->bind_param(4,$_ ->[3]); $sth->bind_param(5,$_ ->[4]); $sth->bind_param(6,$_ ->[5]); $sth->bind_param(7,$_ ->[6]); $sth->bind_param(8,$_ ->[7]); $sth->bind_param(9,$_ ->[8]); $sth->bind_param(10,$_ ->[9]); $sth->bind_param(11,$_ ->[10]); $sth->bind_param(12,$_ ->[11]); $sth->execute(); $dbh->commit(); if ($@) { warn "Database error: $DBI::errstr \n"; $dbh->rollback(); } $dbh->do($sql); $sth->finish(); $dbh -> disconnect (); } #### Can't use string (""06/19/2006","23:59:48","CSCVPN0") as an ARRAY ref while "strict refs" in use at try1.pl line 60, line 1048. #### "06/19/2006","23:59:48","CSCVPN01","Stop","Unknown","Unknown","bmikulka","172.22.0.5","946674","8","1","172.22.0.85","255.255.224.0",,,,,,,,,,,,"ou=pcna","82800","900",,,,"CSCVPN01",,"2","14","108311","503278","000E71F2",,"248","806","821",,,,"5",,"9",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, "06/20/2006","00:00:05","DFWAS1.PBSG.PVT","Stop","tmoy@PBGPPShh","200","tmoy@PBGPPShh","172.21.64.20","392","2","1","172.21.64.86",,,,,,,,,,,,,"SBR-CL DN="tmoy@PBGPPShh" AT="200" VR="SybaseRealm"",,,,"0963","2157251159","DFWAS1.PBSG.PVT",,"2","0","8841","119703","00029926","1","219","79","113","1",,,"0",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, "06/19/2006","23:59:51","DFWVPN01M.PBSG.PVT","Stop","Unknown","Unknown","03138981","172.21.0.5","2042656","8","1","172.21.0.123","255.255.224.0",,,,,,,,,,,,"ou=fritolay","82800","900",,,,"DFWVPN01M.PBSG.PVT",,"2","15","17850309","24857452","001F2B20",,"5276","28956","31809",,,,"5",,"9",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, "06/19/2006","23:59:57","DFWVPN01M.PBSG.PVT","Stop","Unknown","Unknown","02036855","172.21.0.5","2042739","8","1","172.21.0.100","255.255.224.0",,,,,,,,,,,,"ou=troppilot","82800","900",,,,"DFWVPN01M.PBSG.PVT",,"2","9","7621521","15661250","001F2B73",,"4147","29079","27876",,,,"5",,"9",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, "06/20/2006","00:00:06","CSCVPN01","Stop","Unknown","Unknown","01171525","172.22.0.5","946672","8","1","172.22.0.73","255.255.224.0",,,,,,,,,,,,"ou=pcna","82800","900",,,,"CSCVPN01",,"2","11","125891","157892","000E71F0",,"447","621","560",,,,"5",,"9",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,