Article View: news.software.nntp
Article #2518Re: Appearance of description field for newsgroups
From: Eric Engstrom
Date: Mon, 18 Apr 1994 18:54
Date: Mon, 18 Apr 1994 18:54
95 lines
3845 bytes
3845 bytes
In article <766396918snz@solebay.demon.co.uk>, Steve Hartley <steve@solebay.demon.co.uk> wrote:
> In the directory where you keep the 'active' file, there is another file
> called newsgroups. This file contains the name of each news group and a
> short description. ... [munch]
In article <2oocg2$1dh@lyra.csx.cam.ac.uk> jml4@cus.cam.ac.uk (John Line) adds:
> To fill in information for pre-existing groups, you could either ... [munch]
> That won't include local/regional groups, and omits alt groups that uunet
> doesn't carry, but should fill in a lot of the gaps if most of your groups
> currently lack descriptions.
And, to prune your newsgroups file of any duplicate/bogus lines every once
in a while, I've written the following perl script (it's short, so please
humor me :-) ):
-------------------- snip here --------------------
#!/usr/local/bin/perl
#
# FILE: thin-ngfile
#
# perl program to sort and prune the newsgroups file.
# save longest, non-empty, non-bogus ("x", "?", ".") ng-line
#
# USAGE: thin-ngfile [ -n <newsgroups-file> ]
#
# AUTHOR: Eric Engstrom <engstrom@src.honeywell.com>
#
# HISTORY:
# 94/03/10 ee version based on old awk/sed/sh script
##
($progname = $0) =~ s:.*/(.*)(\-\d\.\d)?:$1:;
$progRev = "1.0";
$newsctl = "/news/ctl";
$newsgroups = "$newsctl/newsgroups";
while ($ARGV[0] =~ /^-/) {
$ARGV[0] =~ /^-d(ebug)?/i && ($debug++, shift, next);
$ARGV[0] =~ /^-n(ewsgroup)?/i && (shift, $newsgroups=shift, next);
shift; # toss rest of "-*"
}
# read it
open( NGS, "< $newsgroups" ) || die "Can't open $newsgroups file for reading";
while ( <NGS> ) {
if ( m/^([a-z]*\.[^\s]*)\s*(.*)$/ &&
"$2" ne "" && "$2" !~ /^[x\?\.]$/ &&
length( "$2" ) >= length( "$ngs{$1}" ) )
{ $ngs{$1} = $2 }
}
close( NGS );
# write it
if ($debug) {
for (sort keys %ngs) {
print &ngline($_);
}
} else {
open( NGS, "> $newsgroups" ) || die "Can't open $newsgroups file for writing";
for (sort keys %ngs) {
print NGS &ngline($_);
}
close( NGS );
}
# --- subroutines ---
sub max { ($_[0]>@_[1] ? $_[0] : $_[1]) }
# format newsgroups line w/ standard spacing so descriptions (mostly) line up.
sub ngline {
"$_[0]" .
"\t"x(&max(1,int((3 * 8) + 7 - length($_[0])) / 8)) .
"$ngs{$_[0]}\n"
}
#Local Variables:
# mode: perl
# kept-new-versions: 2
# kept-old-versions: 0
# trim-versions-without-asking: t
#End:
-------------------- snip here --------------------
enjoy,
Eric
--
Eric D. Engstrom, Honeywell Technology Center, SW Technology, Mpls, MN, USA
Research Scientist (& part-time email/news admin) - "finger -l" for more info
engstrom@src.honeywell.com -or- NeXTMail: eric%basilisk@src.honeywell.com
< I eat from the four food groups: Barley, Hops, Yeast, Water. >
Technical Details
Message-ID:
<ENGSTROM.94Apr18185448@riffraff.src.honeywell.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!nntp.gmd.de!xlink.net!news.dfn.de!darwin.sura.net!spool.mu.edu!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!src.honeywell.com!newshost!engstromReferences:
<2ol51t$140i@ctsc.hkbc.hk> <766396918snz@solebay.demon.co.uk> <2oocg2$1dh@lyra.csx.cam.ac.uk>Show Full Headers
Complete Article Headers
Message-ID: <ENGSTROM.94Apr18185448@riffraff.src.honeywell.com> Subject: Re: Appearance of description field for newsgroups Date: Mon, 18 Apr 1994 18:54:48 +0000 From: engstrom@src.honeywell.com (Eric Engstrom) References: <2ol51t$140i@ctsc.hkbc.hk> <766396918snz@solebay.demon.co.uk> <2oocg2$1dh@lyra.csx.cam.ac.uk> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!nntp.gmd.de!xlink.net!news.dfn.de!darwin.sura.net!spool.mu.edu!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!src.honeywell.com!newshost!engstrom Newsgroups: news.software.nntp,news.software.readers Organization: Honeywell Technology Center, Honeywell Inc. Lines: 95 Distribution: inet NNTP-Posting-Host: riffraff.src.honeywell.com In-reply-to: jml4@cus.cam.ac.uk's message of 16 Apr 1994 09:52:02 GMT