Thread View: news.software.readers
4 messages
4 total messages
Started by lvirden
Tue, 15 Nov 1994 19:00
Looking for tool to clean up newsrc file
Author: lvirden
Date: Tue, 15 Nov 1994 19:00
Date: Tue, 15 Nov 1994 19:00
28 lines
2140 bytes
2140 bytes
Specs: 1. I do NOT want to just truncate the lines in my .newsrc file! 2. Tool must be able to handle very long lines. 3. I don't particularly need it do to anything about the ordering of lines within newsrc - I use eep for that. 4. What I do want is something that will wander thru my newsrc file and trim lines I currently have unsubscribed (and the subscribed ones as well perhaps) to reflect the current state of the articles within the NNTP server / active file. for i in lines of newsrc break up line of text , look to see what the lowest article is, set first entry to (either 0 or 1, depending on how things are set currently) thru lowest-1, then, for each of the remaining articles listed, check to see if it is present, and if not, add the number to the list of 'read' articles. Collapse numbers where possible into ranges. Anyone have such a critter? What I would _really_ wish for is the above functionality added to eep - but that's probably too much to hope for. -- :s Great net resources sought... :s Larry W. Virden INET: larry.virden@cas.org :s <URL:http://www.mps.ohio-state.edu/cgi-bin/hpp?lvirden_sig.html> The task of an educator should be to irrigate the desert not clear the forest.
Re: Looking for tool to clean up newsrc file
Author: Dana Carson
Date: Wed, 16 Nov 1994 23:44
Date: Wed, 16 Nov 1994 23:44
89 lines
2970 bytes
2970 bytes
Here is a perl script that does pretty much what you want. Like you
I wasn't happy with losing the fact that I'd marked articles to come
back to. Hope this helps. You may need to customize $NEWSDIR
everything else I think is OK.
--cut here-------------------------------------------------------------
#!/usr/local/bin/perl
$NEWSDIR = "/usr/spool/news/";
if ($ARGV[0] ) {
open(rcfile,$ARGV[0]) || die "Can't open $ARGV[0]";
}
else {
open(rcfile,".newsrc") || die "Can't open .newsrc";
}
while (<rcfile>) {
($group, $seen) = split;
print $group, " ";
# if we read this group we need to trim expired gaps
# if not an empty list will work
if ($group =~ /:/) {
( $GROUPDIR = $group ) =~ s;\.;/;g ;
$GROUPDIR =~ s;:;/;g ;
if (!opendir(CURDIR, $NEWSDIR . $GROUPDIR)) {
print " \n";
next;
}
@filenames = readdir(CURDIR);
closedir(CURDIR);
#find the ones that are numeric and therefore probably articles
@articles = ();
for (@filenames) {
if(/^\d+$/) {
push(@articles,$_);
}
}
@articles = sort bynumber @articles;
# if there are no articles go on to next group
if (!defined($articles[0])) {
print $seen,"\n";
next;
}
$curlow = $articles[0];
#break up the seen list
@seen = split(/,/,$seen);
while (@seen) {
#find any gaps where the articles have expired
#close up the gaps
if ($seen[0] =~ /-/) {
($clow,$chigh) = split(/-/,$seen[0]);
last if $clow > $curlow;
if ($chigh < $curlow) {
shift(@seen);
next;
}
else {
$curlow = $chigh;
shift(@seen);
last;
}
}
else {
last if $seen[0] > $curlow;
shift(@seen);
}
}
@nlist = "1-".$curlow;
@nlist = (@nlist,@seen);
print join(",",@nlist);
#write out the updated seen list
}
print "\n";
}
sub bynumber {
$a <=> $b;
}
--cut here-------------------------------------------------------------
--
Dana Carson
Westinghouse Electronic Systems Group Mail Stop 1615
net: carson@tron.bwi.wec.com | This message on recycled bits.
AT&T: (410) 765-3513 |
WIN: 285-3513 |
Maybe trn? (was: Looking for tool to clean up newsrc file
Author: Peter Kappesser
Date: Thu, 17 Nov 1994 10:02
Date: Thu, 17 Nov 1994 10:02
42 lines
3009 bytes
3009 bytes
Recently in news.software.readers, lvirden@cas.org wrote: > >Specs: >4. What I do want is something that will wander thru my newsrc file and >trim lines I currently have unsubscribed (and the subscribed ones as well >perhaps) to reflect the current state of the articles within the NNTP >server / active file. > > >for i in lines of newsrc > break up line of text , look to see what the lowest article is, set > first entry to (either 0 or 1, depending on how things are > set currently) thru lowest-1, then, for each of the remaining > articles listed, check to see if it is present, and if not, > add the number to the list of 'read' articles. Collapse > numbers where possible into ranges. > >Anyone have such a critter? What I would _really_ wish for is the above >functionality added to eep - but that's probably too much to hope for. Doesn't trn do this as part of its operation? I just did a cursory check, shelling out of trn and comparing the ranges listed in some unsubscribed newsgroups in my .newsrc with those listed in my /tmp/rrnact.* file, and it seemed there were no "stale" articles in the .newsrc. However, this isn't certain, because the news server here has a cluster of unexpired articles from January still hanging around in some newsgroups. So, if you're not using trn to read news, you could use the trnkill script (see the FAQ [** SHAMELESS PLUG **]) to do this. If your main goal is to trim the size of your .newsrc, I've found it effective to just get rid of all the unsubscribed groups (the easy way: cp .newsrc .newsbak ; grep ":" .newsbak > .newsrc ) and run trn with the -q option. (Luckily the news admin here posts the newgroup messages on a local newsgroup, so I just check that to find out what's new. Otherwise you could search for newgroup messages in control.) My .newsrc is about 9K as a result. The only disadvantage I've seen so far is when I subscribe to a (previously) completely unsubscribed newsgroup, I may see some crossposted articles I'd seen before. Big deal. -- pjkappes@mailbox.syr.edu (Peter Kappesser)
Re: Maybe trn? (was: Looking for tool to clean up newsrc file
Author: Mike Castle
Date: Fri, 18 Nov 1994 22:44
Date: Fri, 18 Nov 1994 22:44
27 lines
2264 bytes
2264 bytes
In article <3af9ng$ec6@newstand.syr.edu>,
Peter Kappesser <pjkappes@mailbox.syr.edu> wrote:
>If your main goal is to trim the size of your .newsrc, I've found it
>effective to just get rid of all the unsubscribed groups (the easy way:
>cp .newsrc .newsbak ; grep ":" .newsbak > .newsrc )
>and run trn with the -q option. (Luckily the news admin here posts the
>newgroup messages on a local newsgroup, so I just check that to find out
>what's new. Otherwise you could search for newgroup messages in control.) My
>.newsrc is about 9K as a result. The only disadvantage I've seen so far is
>when I subscribe to a (previously) completely unsubscribed newsgroup, I may
>see some crossposted articles I'd seen before. Big deal.
Hurm.... why run trn with the -q option? Does your newsserver
not support an accurate NEWGROUPS command? If it does, reinstall
trn answering Y to that Configure question and you won't have to
run trn with the -q option, you'll maintain a smaller .newsrc
file, and still be informed of new groups as they're created.
It took me 6 months to convince one of our local sysadmin types
to do this though..... *sigh*
mrc
--
Mike Castle .-=NEXUS=-. Life is like a clock: You can work constantly
mcastle@cs.umr.edu and be right all the time, or not work at all
mcastle@umr.edu and be right at least twice a day. -- mrc
We are all of us living in the shadow of Manhattan. -- Watchmen
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads