Hi Mumia,

I think this one is closer to my goal.

#!/usr/local/bin/perl
use warnings;
use strict;

my $logfile='fortilog';
my $devicefile='deviceid';
our %clientdevice;

open DEVICES, '<', $devicefile or die "Can't open $devicefile $!";

while (<DEVICES>){
  (my $client) = $_ =~ /^(\S+\s+)/;
  (my $device) = $_ =~ /(\S+)$/;
  $clientdevice{$device} = $client;
}
close DEVICES;


open( LOGFILE, '<', $logfile ) or die "Can't open $logfile: $!";
 while(my $log = <LOGFILE> ){
  (my $deviceid) = $log =~ /device_id=(\S+?),/;
  if (exists $clientdevice{$deviceid}){
     open FH, '>>', $clientdevice($deviceid) or die $!;
     print FH $log;
     close FH;
   }
}

The "if exist" line keeps on complaining:

Variable "$clientdevice" is not imported at extractdevice.pl line 23.
Global symbol "$clientdevice" requires explicit package name at 
extractdevice.pl line 23.
syntax error at extractdevice.pl line 23, near "$clientdevice("


Do you know what does this tell?

For those unaware about my goal:
I have a logfile that contains each of our client's firewall logs:
A sample line looks like this.

Jan 10 06:26:17 210.23.194.86 date=2007-01-10 
time=06:30:14,devname=sccp_firewall,device_id=FWF60A123456,log_id=002101000
1,type=traffic,subtype=allowed,pri=notice,vd=root;SN=14435461,duration=139,user=N/A,group=N/A,policyid=11,proto=6,service=750
0/tcp,status=accept,src=192.168.16.23,srcname=192..168.23.5,dst=192.168.1.17,dstname=192.168.1.17,src_int=internal,dst_int=wa
n2,sent=144,rcvd=0,sent_pkt=3,rcvd_pkt=0,src_port=2354,dst_port=7500,vpn=N/A,tran_ip=0.0.0.0,tran_port=0,dir_disp=org,tran_di
sp=noop

Then I made a "deviceid" file which contains:

client1 - FWF60A123456
client2 - FG200A123456
client3 - FS300A123456

The goal is to read the logfile line by line, and if it sees that device_id 
exists in the hash that was created after reading "deviceid" file, then it will 
write that particular log entry in, let's say client1.log.





 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

Reply via email to