Page-a-day Calendars has a very nice online portal to access their daily calendars. The one thing that I wanted though was to bypass the starting up a browser and logging in, so I wrote a couple little programs to get the calendars and mail them to me daily.
There are two shell scripts:
These are run from a crontab entry like:
0 8 * * * ~/get_calendar/mail_calendar.sh -e dys@himinbi.org -p pass -f -c ZENN -n "Zen" dys@himinbi.org 0 8 * * * ~/get_calendar/mail_calendar.sh -e dys@himinbi.org -p pass -f -c DARW -n "Darwin Award" dys@himinbi.org 0 8 * * * ~/get_calendar/mail_calendar.sh -e dys@himinbi.org -p pass -f -c MENS -n "Mensa Question" dys@himinbi.org 30 17 * * * ~/get_calendar/mail_calendar.sh -e dys@himinbi.org -p pass -f -b -c MENS -n "Mensa Answer" dys@himinbi.org
One thing that you might notice is that the Mensa calendar is checked twice a day. This front page (with the question) comes in at 8am and then both the front and back (with the answer) comes in at 5:30pm.
The programs are not terribly complex, but at the same time non-trivial.
The retrieval program has to access multiple pages and store session keys in order to access the site. This 50 lines of shell script in a replacement for 200 lines of java thanks to curl.
The mailing program supports the fact that some calendar pages have embedded images and cross multiple pages. It uses the multipart/related and multipart/mixed sections respectively. It is also sensitive to users with text email readers with multipart/alternative sections. All this was fairly easy thanks to the nmh mail suite.