[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Indlæsning af data fra log til SQL ?



"Brian Ipsen" <sslug@sslug> writes:

>  Jeg har en logfil (med en del linier), som er formatteret i stil med:
>
> Sep 27 16:03:11 127.0.0.1 [ 16:03:11 ] ( info ) Data ID DE56 from port 12 
> (text) target yy
[...]
> Skal man i gang med den store omgang perl for at få det til at lykkedes ?

Nej, det burde kunne laves med et par få linjers perl...

iBog:/tmp brother$ echo 'Sep 27 16:03:11 127.0.0.1 [ 16:03:11 ] ( info
) Data ID DE56 #!/usr/bin/perl -ln

my %months;

BEGIN {
    $i = 0;
    $months{$_} = ++$i for qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct
    Nov Dec);
    %text = (text1 => 17, text2 => 42, text3 => 666);
}

if ( /(\w{3}) (\d\d) (\d\d:\d\d:\d\d) .* ID ([0-9A-F]{4}) .* \(([^)]+)\) target (..)/ ) {
        print "INSERT into xxx VALUES('2006-$months{$1}-$2 $3',",hex $4,"$text{$5},$6)";
}
__END__

-- 
 http://peter.makholm.net/ |     Yes, you can fight it, but in the end the
     sslug@sslug     |          ultimate goal of life is to have fun
                           |                             -- Linus Torvalds


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-10-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *