Article View: news.software.nntp
Article #5781Re: (Q) History and findmissing.pl
From: Jacob Martin Bohn Lorensen
Date: Mon, 18 Mar 1996 00:00
Date: Mon, 18 Mar 1996 00:00
131 lines
4375 bytes
4375 bytes
-----BEGIN PGP SIGNED MESSAGE-----
>>>>> "Paul" == Paul Schaller <paul@cnsnet.com> writes:
In article <4i1od8$hls@flood.xnet.com> paul@cnsnet.com(Paul Schaller) writes:
Paul> In using findmissing.pl it appears that there are a TON of
Paul> articles that don't appear in the history file.
Paul> So what I am
Paul> looking for is maybe a script that uses findmissing.pl and
Paul> either removes these files after finding them, or better yet,
Paul> adds them to the history database.
What I do is run findmissing, then pipe the output to a little perl
script that produces a series of shell commands that would add the
missing articles to the history file. I then feed these commands to
the shell:
findmissing.pl | addmissing.pl
gives a list of shell commands on the form
ctlinnd addhist '<msg-id>' <arrive-time> <expire-time> <paths>
Usually I just mail this to myself, so that I can control what would
be done, but I might as well just feed the output to the shell
directly - just haven't gotten round to do that yet.
Paul> Does such a script/utility exist?
Well, here is my addmissing.pl. No warranty, no nothing, it just seems
to work for me.
Hope this helps,
Jacob.
#!/usr/local/bin/perl
#
# Read stdin lines of the form
# some/news/group/1234
# and add each article listed to the history file using
# ctlinnd addhist .........
#
# Posting date comes from Date: header
# Expire date comes from Expire: header (if present)
# Arrival date comes from Date: header + 2 hours :-(
# Paths comes from Xref: header.
#
$NEWSSPOOL="/usr/spool/news";
$CONVDATE="/usr/lib/news/bin/convdate";
$DEFAULT_DELIVERY_TIME=2*60*60; # seconds
$CTLINND="/usr/lib/news/bin/ctlinnd";
chdir $NEWSSPOOL;
print "## To add any articles found in the news spool and not in\n";
print "## The history files, feed the following lines to your shell\n";
print "\n";
while (<>) {
chop;
($msg_id, $expire_date, $posted_date, $paths) =
&parse_article($_);
next if ($msg_id eq "ERROR"); # File might have gone
next if defined($articles{$msg_id}); # Process each msg-id once only!
$articles{$msg_id} = 1;
if ($expire_date != "") {
$expire_time = &convdate($expire_date);
} else {
$expire_time = 0;
}
$posted_time = &convdate($posted_date);
$arrive_time = $posted_time + $DEFAULT_DELIVERY_TIME;
print "$CTLINND addhist '$msg_id' " .
"$arrive_time " .
"$expire_time " .
"$posted_time " .
"'$paths'" . "\n";
}
exit 0;
#
# Convert date
sub convdate {
local($date) = @_;
open (CONVDATE, $CONVDATE . " -n " . "'$date'" . "|") ||
die "Cannot exec $CONVDATE";
$cd = <CONVDATE>; chop($cd);
close CONVDATE;
return $cd;
}
sub parse_article {
local($art) = @_;
# We only want to process real articles. No dirs or...
(-f $art && open(ART, $art)) || return ("ERROR");
$expire = "";
$paths = $art;
while (<ART>) {
chop;
last if $_ eq "";
/^Message-ID: (<.*>)/ && ($id = $1);
/^Date: (.*)$/ && ($posted = $1);
/^Expires: (.*)$/ && ($expire = $1);
/^Xref: diku.dk (.*)$/ &&
($paths = $1) &&
($paths =~ s![.:]!/!g);
}
close(ART);
return ($id, $expire, $posted, $paths);
}
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2i
iQB1AwUBMU1e/XeWVRfpQLhVAQFKzAL/cVSibSvwoT9wHBxIz0BP1SxLlhooG8tJ
M6Uxx6cWQhQDzpM11RZMVJ4v4WqZBeRbooZ9mjFS11EU5xJiaTAlzwivuAqmtfqc
80ebdo3IXOI8Bk1LoJ7TXNOxrNJh/upp
=aAV1
-----END PGP SIGNATURE-----
--
PGP Key fingerprint = E8 29 D6 EE 25 77 2E B3 17 19 1D FB E9 B2 36 A8
PGP Public key on my home page: <URL:http://www.diku.dk/~jablo/>
Technical Details
Message-ID:
<4ijmua$9qr@odin.diku.dk>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:
<4i1od8$hls@flood.xnet.com>Show Full Headers
Complete Article Headers
Message-ID: <4ijmua$9qr@odin.diku.dk> Subject: Re: (Q) History and findmissing.pl Date: Mon, 18 Mar 1996 00:00:00 +0000 From: jablo@diku.dk (Jacob Martin Bohn Lorensen) References: <4i1od8$hls@flood.xnet.com> 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: 143054442 Distribution: inet Sender: jablo@thor.diku.dk Organization: Department of Computer Science, U of Copenhagen Newsgroups: news.software.nntp