In article <MM.852243445.14514.baugi@ifi.uio.no> you wrote:
# > If list abc gets corrupted, a simple
# >
# > grep 'subscribe abc' LOGFILE
# >
# > gives me all the information I need to reconstruct the list.
# So, is there a simple non-manual way of getting from that format to
# the subscriber file format with only the addresses.
# (and one more thing, you need to subtract the unsubscribes)
I wrote a very quick hack to do this when I lost a number of lists on a
site I run. This script is slow, inefficient, and even makes a bit of a
mess (leaves a couple of files that aren't necessary), but it saved me
an enormous amount of time. This may leave behind a 0-byte length file
or two if you have admin requests in your log file I didn't have in
mine.
Hopefully this will help someone else out there.
#!/usr/local/bin/perl
# mjlog2lists - chomp through majordomo logs, recreating lost mailing lists
# 1996 Eric A. Litman <elitman@viaduct.com>
# This is in the public domain. Do with it as you will. No
# warranty is provided.
# input is a majordomo log file via STDIN
# this script assumes the log files are in date order (unsubscribes
# come after subscribes) and that the process you run is named 'majordomo'
# CHANGE THIS to your mail server's unqualified hostname (i.e. mail1)
$hname = "www";
$debug = 0;
while(<>) {
# change the 'majordomo' to be the name of your mail server process
/[^(?=$hname)*] majordomo\[[0-9]+\] {([^}]+)} ([^ ]+) ([^ ]*) (.*)/;
$send = $1; $op = $2; $list = $3; $name = $4;
if(!grep(/$list/,@lists)) {
($list !~ /(subscribe|unsubscribe|mkdigest|PASSWORD)/) && push(@lists,$list);
}
REQUEST: {
($op eq "subscribe") && (${$list}{lc($name)} = 1, last REQUEST);
($op eq "unsubscribe") && (${$list}{lc($name)} = 0, last REQUEST);
$debug && print "op $op is unknown/irrelevant, line is $_\n";
}
}
$| = 1;
foreach $list (@lists) {
open(LIST,">$list");
foreach $user (keys %{$list}) {
if (${$list}{$user} == 1) {
print LIST "$user\n";
}
}
close(LIST);
}
--
Eric A. Litman Viaduct Technologies, Inc. Bethesda, MD
CEO http://www.viaduct.com (301) 493-0220
digital cellular (PCS) info: http://www.celltalk.com
|
|