Article View: news.software.nntp
Article #24036Re: Adding entries to history
From: Chris van den Berg
Date: Fri, 05 Dec 1997 00:00
Date: Fri, 05 Dec 1997 00:00
152 lines
5151 bytes
5151 bytes
Martin G. Rathmayer wrote:
>
> Has anybody a script to add a list of article files to the existing
> history database ?
Hi,
Below is a script called addhist.pl, which takes a list of articles
names
relative to the spool directory and creates 'ctlinnd addhist' commands.
I've still got some work to do with it, like not creating multiple
addhist
commands for crossposted articles (although it still handles the "paths"
part of the addhist command just fine). This doesn't cause any
problems, it
just creates extra addhist commands which end up getting rejected by
innd
as duplicates.
I ran it over a list of a few thousand articles in a pretty short time
(five minutes?).
The addhist commands themselves will take longer. I dunno if this is
the
fastest way to do this with innd, so if anyone has any ideas, lemme
know.
I typically use the output of "findmissing" as the input for this prog.
You can also get it at:
ftp://agate.berkeley.edu/pub/usenet/addhist.pl
It's still not perfect, so let me know if you have any suggestions.
Chris
--
Chris van den Berg
Programmer/Analyst
Communication and Network Services
(510)643-9837 chrisvdb@ack.berkeley.edu
Key fingerprint = 8B 52 10 58 96 40 E8 9A EA 4B E9 27 F2 29 1A A8
------Begin addhist.pl--------
#!/usr/local/bin/perl5.00401
#Written by Chris van den Berg (chrisvdb@ack.berkeley.edu). If you want
#to redistribute this, that's fine, just make sure to include the
#instructions.
#This script is intended to take a list of articles with pathnames
relative
#to the spool directory, and create output of ctlinnd addhist commands
#with the appropriate parameters. It can be used as part of a pipeline
#with "findmissing"
#e.g. % findmissing | addhist.pl | /bin/sh
#I recommend inspecting the output of findmissing and addhist.pl first,
#rather than just sending the commands onto the shell.
#This script scans the article for a message-ID, and then for a set of
#newsgroups to which it has been crossposted based on the "Xref:"
header.
#Articles which are no longer found are logged to STDERR, and no addhist
#commands are generated.
#The pathnames to the spool and news bin should be set below, as well
#as the arrival, expiration, and posted time. This is the number of
#seconds since the epoch.
#See man ctlinnd(8) for more info.
#You also need to set $hostinoverview as the host field in the Xref:
header.
#e.g. on agate we have "Xref: agate ucb.org.foo:666", so $hostinoverview
#is set to 'agate'.
$spool='/var/spool/news/';
$ctlinnd='/usr/local/news/bin/ctlinnd';
$addhist='addhist';
$arr='44';
$exp='55';
$post='66';
$hostinoverview='agate';
#Read in a list of article pathnames relative to the spool directory.
#Get the Message-ID and the list of Newsgroups.
&getartname;
#loop through the list of article files
sub getartname {
while (<>) {
$artfile="$spool"."$_";
&scan;
}
close(ARTFILE);
exit 0;
}
sub scan {
$paths="";
open(ARTFILE,"$artfile") || ¬found;
while (<ARTFILE>) {
#Find the Xref: header, but ignore the hostname between
it
#and the start of the list of newgroups.
if (/Xref:\s+$hostinoverview\s+/) {
#if (/Xref:\s+\w+\s+/) {
@crossposts=split(' ',$');
&makecrosses;
}
if (/Message-ID:\s+/) {
$id=$';
chomp $id;
}
#Read until the end of the header, then generate the
command.
&printadd if /^$/;
}
}
sub printadd {
$paths =~ s/ $//; #get rid of the trailing space, if any.
print "$ctlinnd $addhist \'$id\' $arr $exp $post \"$paths\"\n";
&getartname; #return to the top
}
#make a list of paths for the crossposts.
sub makecrosses {
foreach (@crossposts) {
s/\./\//g;
s/:/\//g;
$paths .= $_;
$paths .= " " if $#crossposts;
}
}
#print to STDERR if the article was expired since findmissing
was run.
sub notfound {
chomp $artfile;
print STDERR "$artfile not found, deleted?\n";
&getartname; #return to the top
}
-------End addhist.pl----------
Technical Details
Message-ID:
<34883FF8.794BDF32@ack.berkeley.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-mailReferences:
<668lb9$p8p@news.tuwien.ac.at>Show Full Headers
Complete Article Headers
Message-ID: <34883FF8.794BDF32@ack.berkeley.edu> Subject: Re: Adding entries to history Date: Fri, 05 Dec 1997 00:00:00 +0000 From: Chris van den Berg <chrisvdb@ack.berkeley.edu> References: <668lb9$p8p@news.tuwien.ac.at> 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: 295522495 Distribution: inet To: "Martin G. Rathmayer" <rathmaye@mgr.kom.tuwien.ac.at> Organization: University of California, Berkeley Newsgroups: news.software.nntp