sendme -- fetch usenet articles by Message-ID
Ed Vielmetti
emv at ox.com
Wed Jan 2 12:24:20 AEST 1991
>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 at murdoch.acc.Virginia.EDU /usr/local/lib/news/history
In article <1085 at toaster.SFSU.EDU> eps at 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 at ox.com
#!/usr/local/bin/perl
# sendme -- fetch usenet articles by Message-ID.
# usage --
# sendme 1234 at host.domain.org
# sendme "<1234 at host.domain.org>"
# sendme 1234 at host.domain.org nntpserver.domain.org
# sendme "<1234 at 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 at 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 = <N>;
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 = <N>;
if ($response !~ /^2/) { # hunky dory
print STDERR $response;
exit 1;
}
} else {
die "Don't know how to do history lookups yet." ;
}
while(<N>) {
if ($NNTPSERVER && $_ eq ".\r\n") {
last;
}
s/.$//; print ;
}
if ($NNTPSERVER) {
send(N, "QUIT\r\n", 0);
}
close(N);
More information about the Alt.sources
mailing list