Xref: utzoo news.newusers.questions:3596 alt.sources:2913 Path: utzoo!utgpu!cs.utexas.edu!samsung!umich!ox.com!ox.com!emv From: emv@ox.com (Ed Vielmetti) Newsgroups: news.newusers.questions,alt.sources Subject: sendme -- fetch usenet articles by Message-ID Message-ID: Date: 2 Jan 91 01:24:20 GMT References: <1990Dec28.214141.6681@murdoch.acc.Virginia.EDU> <1990Dec29.014722.25213@midway.uchicago.edu> <1085@toaster.SFSU.EDU> Sender: usenet@ox.com (Usenet News Administrator) Organization: OTA Limited Partnership, Ann Arbor MI. Lines: 114 In-Reply-To: eps@toaster.SFSU.EDU's message of 1 Jan 91 03:37:13 GMT >Like this? (Your mileage may vary; I'm intimate only with C News on >my Sun OS 4.0.3 system. I've wrapped lines for readability.) > > % grep 1990Dec28.202628.5720@murdoch.acc.Virginia.EDU /usr/local/lib/news/history In article <1085@toaster.SFSU.EDU> eps@toaster.SFSU.EDU (Eric P. Scott) writes: Um, history files tend to be several megabytes long, and this isn't a particularly efficient way to find things. I believe C News is distributed with a "newshist" program for fast lookups. B News sites needing similar functionality can FTP the shar file pub/newshist from sutro.sfsu.edu [130.212.15.230]. NNTP sites can already access articles directly by Message-ID. If you are on an NNTP-only site this little bit of perl might help; given a message-id, it fetches the article from any arbitrary NNTP site that allows such access and sends it to standard output. --Ed emv@ox.com #!/usr/local/bin/perl # sendme -- fetch usenet articles by Message-ID. # usage -- # sendme 1234@host.domain.org # sendme "<1234@host.domain.org>" # sendme 1234@host.domain.org nntpserver.domain.org # sendme "<1234@host.domain.org>" nntpserver.domain.org # it should do the following: # cope with B and C formats in dbm or flat file format # cope with NNTP to the default server # cope with NNTP to any server specified, or a list to try. # but it doesn't. instead it just uses NNTP. # suggested by eci386!clewis # socket code mailed to me by cmf@obie.cis.pitt.edu (Carl M. Fongheiser) # Configuration information -- change to reflect your site. $DEFAULTSERVER='nntpserver.domain.org'; # Configure here $NNTPSERVER=$ARGV[1] ? $ARGV[1] : $DEFAULTSERVER ; # should also read dbm or grep # history file. $NEWS='/usr/spool/news/lib/news'; # news library $SPOOL='/usr/spool/news'; # news spool # $DEBUG = 1; # uh, if it don't work $art = $ARGV[0]; print $art if ($DEBUG); if ($art !~ m#^<#) { $art = "<" . $art . ">"; } print $art if ($DEBUG); if ($NNTPSERVER) { $port = 'nntp'; require 'sys/socket.ph'; $sockaddr = 'S n a4 x8'; chop($hostname = `hostname`); ($name,$aliases,$proto) = getprotobyname('tcp'); ($name,$aliases,$port) = getservbyname($port, 'tcp') unless $port =~ /^\d+$/; ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname); ($name,$aliases,$type,$len,$thataddr) = gethostbyname($NNTPSERVER); $this = pack($sockaddr, &AF_INET, 0, $thisaddr); $that = pack($sockaddr, &AF_INET, $port, $thataddr); socket(N, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!"; bind(N, $this) || die "bind: $!"; connect(N, $that) || die "connect: $!"; $response = ; if ($response !~ /^2/) { # hunky dory print STDERR $response; exit 1; } send(N,"ARTICLE $art\r\n",0); print STDERR "ARTICLE $art\r\n" if ($DEBUG); $response = ; if ($response !~ /^2/) { # hunky dory print STDERR $response; exit 1; } } else { die "Don't know how to do history lookups yet." ; } while() { if ($NNTPSERVER && $_ eq ".\r\n") { last; } s/.$//; print ; } if ($NNTPSERVER) { send(N, "QUIT\r\n", 0); } close(N);