Thread View: news.software.nntp
3 messages
3 total messages
Started by Mike Wilson
Mon, 29 Dec 1997 00:00
Text file to News/NNTP posting
Author: Mike Wilson
Date: Mon, 29 Dec 1997 00:00
Date: Mon, 29 Dec 1997 00:00
13 lines
850 bytes
850 bytes
Is there a package/perl script that will allow me to post a message to a nntp host? I produce some stats on the news server that I would like to auto-post to a local group. Thanks for any information! -- --- Mike Wilson http://www.drwho.org http://vweb02.onramp.net/~mikew
Re: Text file to News/NNTP posting
Author: Steve Rawlinson
Date: Mon, 29 Dec 1997 00:00
Date: Mon, 29 Dec 1997 00:00
90 lines
2268 bytes
2268 bytes
>> Is there a package/perl script that will allow me to post a message to a
>> nntp host? I produce some stats on the news server that I would like to
>> auto-post to a local group.
Here's a script I use to post announcements which are piped to stdin.
You'll need to change the header strings, obviously.
steve
#!/usr/bin/perl
use Socket;
use FileHandle;
my ($remote, $port, $iaddr, $paddr, $proto, $line);
$remote = 'news.clara.net';
$port = 'nntp';
$port = getservbyname($port, 'tcp'); print "port: $port\n";
$iaddr = inet_aton($remote);
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
# read in the article
chop($date = <STDIN>);
chop($subject = <STDIN>);
@body = <STDIN>;
$lines = @body;
# construct header
$head = "From: ClaraNET Announce <announce\@clara.net>
Newsgroups: claranet.announce,claranet.systems
Followup-To: claranet.systems
Subject: $subject
Date: $date
Lines: $lines\n\n";
$article = sprintf ("$head @body\n.\n");
socket (SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect (SOCK, $paddr);
autoflush SOCK 1;
$sock = <SOCK>;
if ($sock =~ /^200.*posting ok/) {
# ok to continue
print "received: $sock";
print SOCK "POST\n";
$sock = <SOCK>;
print "received: $sock";
if ($sock =~ /^340 Ok/) {
print SOCK $article;
} else {
print "ERROR\n";
print SOCK "QUIT\n";
exit 1;
}
} else {
# error
print "ERROR: $sock\n";
print "QUIT\n";
}
$sock = <SOCK>;
print "received: $sock";
print SOCK "QUIT\n";
exit 0;
--
Steve Rawlinson
ClaraNet Ltd
steve@clara.net
0171 903 3000
Re: Text file to News/NNTP posting
Author: Andrew Gierth
Date: Mon, 29 Dec 1997 00:00
Date: Mon, 29 Dec 1997 00:00
43 lines
2075 bytes
2075 bytes
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:
> Steve Rawlinson <steve@clara.net> writes:
>> Here's a script I use to post announcements which are piped to stdin.
>> You'll need to change the header strings, obviously.
Russ> Here's the same script, rewritten to use Net::NNTP:
[snipped]
Alternatively:
#!/usr/bin/perl
use News::FormArticle;
my $date = <STDIN>;
my $subject = <STDIN>;
my @data = <STDIN>;
my $art = new News::FormArticle("article.tpl", sub { eval shift; });
die "failed to construct article" unless $art;
$art->post();
where article.tpl looks something like
From: ClaraNET Announce <announce@@clara.net>
Newsgroups: claranet.announce,claranet.systems
Followup-To: claranet.systems
Subject: $subject
Date: $date
@data
(you can put boilerplate text, sig or whatever in the template if you like)
News::FormArticle is part of News::Article, which is only alpha-ish
but in use in various places (including my own daily auto-posts to
news.admin.net-abuse.bulletins). Now available from
http://www.erlenstar.demon.co.uk/perl and shortly from CPAN. (Needs
Net::NNTP and a few other modules too.)
--
Andrew.
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