For years NNTP was the standard way news articles were distributed across the internet (and even I dare say, non internet machines via UUCP or even SOUP packets.)
I happen to think news systems are a better tool for the job and I prefer to use a newsreader program to read news, including RSS "news feeds" or perhaps an email client.
This little project will convert an RSS feed into plain text, where it can be
sent through email or posted to a news server with a tool like inews (or
directed to /dev/null saved to a file, whatever)
The nice thing about using a "real news system" is that your .newsrc is updated
automatically. It's a bit of a pain to set up though.
I use a local news server to store spam emails, that way they are automatically purged after a few days just like news articles. This purge time gives me a chance to look over the queue, in case I need to fetch an email spamassassin had flagged as spam.
News servers are also useful for storing other automatically generated reports, mailing lists and things of that nature. With news, you don't have to remember to purge old messages. The news software does this for you automatically.
It uses the unix tradition of standard input, standard output. For convenience,
it does know about URL's by way of LWP::Simple (Although you might want
to use a tool like curl for authentication and so-forth)
It was inspired by Leonid Mamchenkov and his rss2mail program.
It's not the greatest at formatting the HTML found in these feeds, but it does try to weed out some of the tags and insert line breaks where it thinks they ought to go. It'll strip out the utf8 stuff as best it can (via Encode) so that the output resembles plain-old text.
Channel: Weird Life news
Link: http://weird.podro.com
Description: Weird Life is a site dedicated to the weirdness of life and
general geek things. Online quizes, etc..
------------------------------------------------------------------------------
Summary of items
1 Email + Plain text, bad news
==============================================================================
1) Title: Email + Plain text, bad news
Url: http://weird.podro.com/gouf/art/text_mail/
Date: Thu, 09 Nov 2006 19:30:00 GMT
Description: Gurus will say, all unhappiness is caused by attachment. In
the case of email, unhappiness is caused by attachments(s)
cat file.rss | rss2ascii.pl | more
filenameIf specified, it will read from filename instead of standard input.
urlIf specified, it will fetch the feed URL and parse that instead.
If specified, items with links found in /path/to/cache/file will not be sent
to the output. (This is useful if you would like to skip items you have already
seen)
If specified, will send to file.txt
If you want to do fancy tricks, such as posting to news servers or setting your own subject line, you will need to have a program that handles this. While it would be quite easy to just have perl do it (and in fact, that is what I do) I wanted to keep posting news or sending email as separate actions. That way you can introduce your own commands "in the pipeline" as you see fit.
Both sendmail and inews should handle this nicely, however you may need to write a small wrapper script around it for news headers, subjects and so on.
If you just want the RSS feed emailed to you, merely placing it in your crontab is enough. Cron can handle the email part for you.
header_rss(){
cat <<__EOH
Subject: This is a test.
To: $TO
From: My email address here. <root@localhost>
Newsgroups: $NEWSGROUP
-- rss2ascii output follows --
__EOH
#
# This is the command that does it.
#
perl rss2ascii.pl --in $1 --history $RSS_HIST
cat <<__EOH
--
http://weird.podro.com/gouf/
__EOH
}
The above is just a simple little shell script that produces a header/footer on it's output along with the output of rss2ascii, so you can direct it into sendmail or inews.
You could just as well have said something like this:
header_rss(){
cat headers.txt
echo "\n"
perl rss2ascii.pl --url $1
echo "\n-- \n";
cat signature.txt
}
Then to run it, you'd use it just like any other command:
header_rss http://weird.podro.com/rss.xml | sendmail -t -oi
freshmeat.com insisted I place a license some place. I'll list it as being under the GPL .
I've also got some other toolkits that go along with it, including a nasty looking shell script that will read the urls from a simple "shell style" database. Perl might have been better at parsing out such a data file, but I like to use shell now and then because of it's creativity.
Plenty I suppose. The HTML formatting needs a bit of work, I wanted something
simple that used modules you likely already had. XML::RSS is probably the
only thing you'll need to install:
perl -MCPAN -e shell install XML::RSS