Boston Linux & UNIX was originally founded in 1994 as part of The Boston Computer Society. We meet on the third Wednesday of each month at the Massachusetts Institute of Technology, in Building E51.

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



    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.



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org