[Discuss] I'm looking for a "lightweight" nntp client

Daniel Hagerty hag at linnaean.org
Sun Oct 28 11:25:19 EDT 2012


    Lightweight would be a shell script that uses netcat for the post.

#!/bin/sh

msgid=`date +%Y%m%d-%H%M%S at linnaean.org`

perl -pe 's/\n/\r\n/'  <<_EOF_ | nc localhost 119
takethis <$msgid>
Path: you!me
Newsgroups: linnaean.test
Message-ID: <$msgid>
Date: `date "+%a, %d %b %Y %H:%M:%S %z"`
From: Daniel Hagerty <hag at linnaean.org>
Subject: $1

`cat`
.
quit
_EOF_

    You use it like this:

$ /tmp/post "this is a subject" < /tmp/body
200 perdition.linnaean.org InterNetNews server INN 2.4.6 ready
239 <20121028-112226 at linnaean.org>
205 .
$

    If all goes well, you should see a 2xx line for the server banner, a
2xx reply for the takethis, and another 2xx response for the quit.

    This script uses takethis for the post; I can't imagine any news
server doesn't implement it by now.  Older ihave is possible, but a few
more lines and more room for wrong.

    All of the headers are required; adjust them as needed.

    The perl bit is to handle NNTP demanding MS-DOS style crlf line
endings.

    It does absolutely no error checking, doesn't attempt to quote any
body line containing a sole ".", and hasn't had its rabies shots.  Most
of these things could be done, but would take it over the ten minute
example.



More information about the Discuss mailing list