Read the webalizer DNS cache file with Perl
Problem
You're writing a Perl program that wants to read the webalizer cache file.
Keywords
Webalizer, Perl, DB_File, BerkeleyDB, webalizer, cache, DNS, domain, name.
Solution
The following Perl program is your friend. You need the libberkeleydb-perl
package.
#!/usr/bin/perl -w
#
# Copyright (C) 2004 Thomer M. Gil [https://thomer.com/]
#
# This program is free software. You may distribute it under the terms of
# the GNU General Public License as published by the Free Software
# Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# This little program reads the webalizer.cache file (in the current
# directory) and prints its contents in "ip = name" format.
#
# This program is inspired by: http://sysd.org/proj/wdcv.pl
# (by Stanislaw Yurievich Pusep, SysD Destructive Labs).
#
use BerkeleyDB;
my $file = "webalizer.cache";
my %cache = ();
tie %cache, 'BerkeleyDB::Hash', -Filename => $file or die "tie failed: $!";
while(my ($key, $val) = each %cache) {
my $name = (unpack('L L A*', $val))[2];
print "$key = $name\n";
}
untie %cache;
URL:
https://thomer.com/howtos/webalizer_cache.html
Copyright © 1994-2022 by Thomer M. Gil
Updated: 2004/09/16