Article View: news.software.nntp
Article #7951suck + suckit.pl for microsoft.* groups
From: Iain Lea
Date: Fri, 24 May 1996 00:00
Date: Fri, 24 May 1996 00:00
132 lines
3139 bytes
3139 bytes
After using Suck 2.6.3 to pull the microsoft.* groups onto our server
and finding that we were getting broken connections due to timeouts I
whipped up this little script to cycle thru the newsrc file to read
only 3 (settable via $NumGroups) groups, download them, feed them to
rnews and then goto next 3 groups in the list.
Works here... YMMV.
Iain
--snip--
#!/usr/local/bin/perl
#
# Harness to get MS newsgroups via *overloaded* connections
#
# Run from cron as needed
#
# Change variables to suit your site
#
$NumGroups = 3;
$FeedName = "msnews.microsoft.com";
$RnewsDir = "/usr/local/news/bin";
$SuckDir = "/usr/local/news/suck";
$BatchDir = "/news/in.coming";
#
# Don't change anything below here!
#
$Newsrc = "sucknewsrc$FeedName";
$BatchFile = "$BatchDir/$FeedName";
$SuckFlags = "-a -dt $BatchDir -p $FeedName -br $BatchFile";
$MaxGroups = `wc -l $Newsrc`;
($LoMark, $HiMark) = &FindStartPoint ($Newsrc, $NumGroups);
chdir ($SuckDir);
$SuckCmd = "$SuckDir/suck $FeedName $SuckFlags";
$| = 1;
while ($LoMark < $MaxGroups) {
&SetupNewsrc ($Newsrc, $LoMark, $HiMark);
printf "RUN [%04d - %04d] %s\n", $LoMark, $HiMark, $SuckCmd;
if (open (SUCK, "$SuckCmd |")) {
while (<SUCK>) {
print;
}
close (SUCK);
if (-f $BatchFile) {
$RnewsCmd = "$RnewsDir/rnews -S localhost $BatchFile";
print "$RnewsCmd\n";
if (open (RNEWS, "$RnewsCmd |")) {
while (<RNEWS>) {
print;
}
close (RNEWS);
print "Deleting $BatchFile\n";
unlink ($BatchFile);
} else {
print "Warning: RNEWS - $!\n";
}
}
} else {
print "Warning: SUCK - $!\n";
}
$LoMark += $NumGroups;
$HiMark += $NumGroups;
}
exit 0;
#############################################################################
#
#
sub FindStartPoint
{
my ($Newsrc, $NumGroups) = @_;
my ($Line, $Lo, $Hi);
$Line = $Lo = 0;
$Hi = $NumGroups;
open (NEWSRC, "$Newsrc") || die "Error: $Newsrc - $!\n";
while (<NEWSRC>) {
if (/^[A-z]/) {
$Lo = $Line;
$Hi = $Lo + $NumGroups;
break;
}
$Line++;
}
close (NEWSRC);
return ($Lo, $Hi);
}
sub SetupNewsrc
{
my ($Newsrc, $LoMark, $HiMark) = @_;
my ($Line) = 0;
open (OLD, "$Newsrc") || die "Error: $Newsrc - $!\n";
open (NEW, ">$Newsrc.tmp") || die "Error: $Newsrc.tmp - $!\n";
while (<OLD>) {
s/#\ //g;
if ($Line >= $LoMark && $Line < $HiMark) {
printf "GET [%04d] $_", $Line;
print NEW;
} else {
print NEW "# $_";
}
$Line++;
}
close (NEW);
close (OLD);
`mv $Newsrc.tmp $Newsrc`;
}
Technical Details
Message-ID:
<4o4coc$j7l@millie.scn.de>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-mailShow Full Headers
Complete Article Headers
Message-ID: <4o4coc$j7l@millie.scn.de> Subject: suck + suckit.pl for microsoft.* groups Date: Fri, 24 May 1996 00:00:00 +0000 From: iain@scn.de (Iain Lea) 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: 156618549 Organization: Siemens Corporate Network Followup-to: poster Newsgroups: news.software.nntp