Re: hostnames in log?

From: Martin Gleeson <[email protected]>
Date: Mon, 1 Jul 1996 14:12:52 +1000

Oh, by the way, if you don't need something as complicated as what I posted
before, try the following:

#!/usr/local/bin/perl

$address_type=2;

while( <STDIN> )
{
    chop;
    ($host, $rest) = /^(\S+) (.+)$/;

    if( $hosts{$host} )
    {
        $name = $hosts{$host};
    }
    else
    {
        if($host =~ /\d\d\.\d\d/)
        {
            @address = split(/\./,$host);
            $addpacked = pack('C4',@address);
            ($name,$aliases,$addrtype,$length,@addrs) =
gethostbyaddr($addpacked,$address_type);
        }
        $name = $host if ($name eq "");
        $name = "\L$name";
        $hosts{$host} = $name;
    }

    print "$name $rest\n";
}

Cheers,
Marty.
-------------------------------------------------------------------------
Martin Gleeson Webmeister | http://www.unimelb.edu.au/%7Egleeson/
Information Technology Services | Email : gleeson@unimelb.edu.au
The University of Melbourne, Oz. | Opinions : Mine, all mine.
       "I hate quotations" -- Ralph Waldo Emerson; Journals (1843)
-------------------------------------------------------------------------
Received on Sun Jun 30 1996 - 21:44:48 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:32:33 MST