🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #46629

batchpurge.pl, an alternative to innxmit -p

#46629
From: Jack Bryans
Date: Sun, 28 May 2000 00:00
63 lines
2295 bytes
Using innxmit -p to purge a batchfile of entries that refer to files
that no longer exist took a couple of hours on batchfiles around 200K
lines, time better spent slogging thru the batch.  I tried a different
approach in perl that knocked the hours down to minutes.

Batchpurge.pl discards article numbers below their min in the active
file.  It catches nearly all routinely expired articles (an honored
Expires header can cause exceptions), but doesn't catch canceled
articles.  For old batches, it catches the vast majority of missing
articles.

It recognizes by content innfeed .input and .output files and does the
right thing.  Its output is to stdout so you can use redirection to
stash it anywhere, or, better yet, pipe it thru a sort to improve
efficiency at both ends.

There are three lines to edit in the beginning to adapt to your setup.

#!/usr/local/bin/perl

# Edit the next 3 assignments for your newspool path, the path to your
# active file, and one or more | joined local hierarchies not sent
# offsite.  The exclusions are groups with j, x, or = flags, in addition
# to the local hierarchy

$spool = '/var/spool/news' ;

$active = '/usr/local/news/active' ;

$exclude = '^local|=|[jx]$';

open(BATCH,$ARGV[0]) || die "Can't open $ARGV[0]";

open(ACTIVE,"egrep -v '$exclude' $active |") || die "Can't open $active";

while (<ACTIVE>) {
    ($grp,$max,$min,$flg) = split;
    $ng{$grp} = $min;
}

close ACTIVE;

chdir($spool) || die "Can't cd $spool";

$_ = <BATCH>;

$offset = /^(\d+)\s*$/ ? $1 : 0;

seek(BATCH,$offset,0);

while (<BATCH>) {
    ($art,$rest) = split;
    @grp = split(/\//,$art);
    $art = pop @grp;
    $grp = join('.',@grp);
    print unless $art < $ng{$grp};
}

close BATCH;

Jack

Technical Details
Message-ID: <2hya4urzi9.fsf@swift.csulb.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <2hya4urzi9.fsf@swift.csulb.edu>
Subject: batchpurge.pl, an alternative to innxmit -p
Date: Sun, 28 May 2000 00:00:00 +0000
From: Jack Bryans <jbryans@swift.csulb.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 628418155
Organization: Cal State Long Beach
Newsgroups: news.software.nntp