Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2003 16:34:57 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Warren Block <wblock@wonkity.com>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: IPFW Log question
Message-ID:  <20030620153457.GA2304@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <20030620081951.G12793@wonkity.com>
References:  <20030620130049.63710.qmail@web10002.mail.yahoo.com> <20030620134326.GA615@happy-idiot-talk.infracaninophile.co.uk> <20030620081951.G12793@wonkity.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--qMm9M+Fa2AknHoGS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jun 20, 2003 at 08:21:52AM -0600, Warren Block wrote:
> On Fri, 20 Jun 2003, Matthew Seaman wrote:
>=20
> > > Or if anyone has a perl script that tosses out the odd
> > > lines and just keeps the full lines and is willing to
> > > share it, that would work too. Otherwise, I am going
> > > to have to get better at perl in a big way.
> >
> >     #!/usr/bin/perl -w
> >
> >     $prevline =3D "";
> >
> >     while (<>) {
> >         if (m/last message repeated (\d+) times/) {
> >             for ( 1 .. $1 ) {
> >                 print $prevline;
> >             }
> >         } else {
> >             print $_;
> >             $prevline =3D $_;
> >         }
> >     }
>=20
> If I read that right, this would also work:
>=20
> #!/usr/bin/perl -w
>=20
> while (<>) {
> 	print $_ unless $_ =3D~ /last message repeated (\d+) times/;
> }

That's not quite the same thing.  You're just taking out the lines
that match /last message repeated \d+ times/ (and constructing a
backreference to \d+ that you never use):

    Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21=
=2E43.65.87:4321 out via de0
    Jun 20 16:26:27 example last message repeated 2 times

becomes:

    Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21=
=2E43.65.87:4321 out via de0

whereas I'm replacing that line with the correct number of repeats of
the original line, so the example becomes:

    Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21=
=2E43.65.87:4321 out via de0
    Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21=
=2E43.65.87:4321 out via de0
    Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21=
=2E43.65.87:4321 out via de0

Of course, on closer reading, your code is exactly what the OP asked for.

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--qMm9M+Fa2AknHoGS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQE+8ymhdtESqEQa7a0RAhR6AKCDqpWm4KD7x/P40+EyxZ0cNklF3gCbBSct
YV0QV2p5zq2q5pGJjCOwDrg=
=YzQ3
-----END PGP SIGNATURE-----

--qMm9M+Fa2AknHoGS--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030620153457.GA2304>