Cheap and Cheerful News

By Paul Dunne <paul@tiny1.demon.co.uk>

Can't be bothered with setting up C-NEWS? Weary of the expense of reading news on-line? A suite of programs called "Suck" could provide an answer. It is perfect for me, as I am not interested in, nor do I have the time to follow, long-winded Netnews discussions. Typically, most of my news reading time is spent saving articles to MH folders, so suck cuts out the middleman (ouch!).

Suck connects to a news server, specified on the command line or defined in the environment variable NNTPSERVER, and writes all new articles from specified newsgroups to STDOUT. The newsgroups are specified in the file sucknewsrc, in the format

To subscribe to a new group, simply put 0 as the last message.

I use a simple sed script - sed '/s^\./^A^A^A^A/' (where ^A is Control A) - to convert the down-loaded data so that it can be "burst" by MH into individual messages, and writes it to a file, which the MH command "inc" then processes. You can of course replace this with the processing of your choice. It would be easy to write a perl script to put the messages in a local news spool, so that you could read them with trn, for example. (I have a similar script for processing my messages from Cix - I will send it to anyone interested).

Of course, reading news is all very well, but it is nice to be able to answer back. A companion program to suck handles this. rpost reads STDIN and writes to your NNTP server. A shell script included with the suck distribution, called (wait for it!) blow, automates this process by taking a list of file names and piping them to rpost.

Here are the scripts that I use to automate my news handling. Yes, they are fairly primitive: flames to /dev/null, please.

The first, sucknews, calls getnews and postnews to do the actual work. This is because my internet connection is made as root, so I need to do a 'su -c' to get news for a particular user. Sucknews is called from a dial-up script which is run at six a.m. every day by cron.

#!/bin/sh
#sucknews: get and post news
case $# in
    0) echo "Usage: sucknews user"; exit 1;;
esac
user=$1
su -c '/usr/local/bin/getnews "$user"' $user
su -c '/usr/local/bin/postnews "$user" $user
exit 0
The next, getnews, gets the articles from the server, converts them to an MMDF file format (a mail transport agent which separates mail messages in a file by a line of four Ctrl-As), then uses the MH program inc to split the file into its constituent messages and put them in an MH folder called "news".
#!/bin/sh
#getnews: get news from NNTP server, put in news folder
case $# in
    0) echo "Usage: getnews user"; exit 1;;
esac
user=$1
cd
cd suck
export NNTPSERVER=news.demon.co.uk
if test -f suck.tmp
then
    cp suck.tmp sucknewsrc
fi
suck | sed 's/^\.$/^A^A^A^A/' > suck.inc
/usr/bin/mh/inc -file suck.inc +news
exit 0
Finally, postnews looks in a subdirectory of suck - postbox - and posts all the files found there - these should of course be in the correct format for an article, with "Newsgroup" and "Subject" lines.
#!/bin/sh
#postnews:post one or more articles from postbox to NNTP server
case $# in
    0) echo "Usage: postuser"; exit 1;;
esac
user=$1
export NNTPSERVER=news.demon.co.uk
cd
cd suck/postbox
blow *
mv ~/suck/postbox/* ~/suck/outbox
exit 0
I got my copy from the August 1995 Linux Developer's Resource, by Infomagic, from the sunsite mirror disk, so it is on sunsite and its mirrors. The README file credits one "goldt@math.tu-berlin.de". I know nothing more about it than this!