🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #71680

Re: simple Perl script needed

#71680
From: Szymon Sokół
Date: Tue, 24 May 2005 07:49
39 lines
2977 bytes
In news.software.nntp sebhoff2002@yahoo.com wrote:
> Yes - I had already tried this. But it's very slow to retrieve
> everything - because of the news server... What I need now is something
> that just gets the headers - quick. ;-) Will look into it and see how I
> can change the script.
Well, if you need something simple, short and fast (but not tested very
thoroughly and without any error handling...):

#!/usr/bin/perl -w
use Net::NNTP; 
# customize these 3 lines according to your needs
my $output = "/directory/where/output/goes/";
my $nntpserver = "news.somedomain.com";
my @groups = ("news.software.nntp", "news.software.readers");

my $nntp = Net::NNTP->new($nntpserver);
$| = 1;
for my $group (@groups) {
  my $file;
  open $file, ">${output}/$group";
  my $all = $nntp->listgroup($group);
  my $total = scalar @$all;
  printf "Group $group, total of %d messages\n", $total;
  my $j = 1;
  for my $msg (@$all) {
    printf "Getting #%d of %d message headers\r", $j++, $total;
    $nntp->head($msg,$file);
    print $file "\n"; # an empty line separates headers
  }
  close $file;
  print "\n";
}
$nntp->quit;

-- 
Szymon Sokół (SS316-RIPE) -- Network Manager                                B
Computer Center, AGH - University of Science and Technology, Cracow, Poland O
http://home.agh.edu.pl/szymon/ PGP key id: RSA: 0x2ABE016B, DSS: 0xF9289982 F 
Free speech includes the right not to listen, if not interested -- Heinlein H
Technical Details
Message-ID: <d6umac$o5g$1@galaxy.uci.agh.edu.pl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!newsfeed.pionier.net.pl!newsfeed.silweb.pl!agh.edu.pl!news.agh.edu.pl!not-for-mail
References: <1116840238.189967.41700@o13g2000cwo.googlegroups.com> <tskirvin.20050523173603$2bdd@cairo.ks.uiuc.edu> <1116917630.486426.100140@z14g2000cwz.googlegroups.com>

Show Full Headers
Complete Article Headers
Message-ID: <d6umac$o5g$1@galaxy.uci.agh.edu.pl>
Subject: Re: simple Perl script needed
Date: Tue, 24 May 2005 07:49:32 +0000
From: Szymon Sokół <szymon@bastard.operator.from.hell.pl>
References: <1116840238.189967.41700@o13g2000cwo.googlegroups.com> <tskirvin.20050523173603$2bdd@cairo.ks.uiuc.edu> <1116917630.486426.100140@z14g2000cwz.googlegroups.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!newsfeed.pionier.net.pl!newsfeed.silweb.pl!agh.edu.pl!news.agh.edu.pl!not-for-mail
Newsgroups: news.software.nntp,news.software.readers
Followup-To: news.software.nntp
Organization: University of Mining & Metallurgy
Lines: 39
Sender: Szymon Sokol <szymon@galaxy.uci.agh.edu.pl>
NNTP-Posting-Host: galaxy.uci.agh.edu.pl
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: 8bit
X-Trace: galaxy.uci.agh.edu.pl 1116920972 24752 149.156.96.9 (24 May 2005
X-Complaints-To: usenet@uci.agh.edu.pl
NNTP-Posting-Date: Tue, 24 May 2005 07:49:32 +0000 (UTC)
User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (SunOS/5.8 (sun4u))