iCal is a great application, but there are some things about it that bug me.
Apple really want you to pay money for their .mac service, and as such if you want to publish your calendars, it’s either that or set up WebDAV. Now I run my own server, and I could probably install WebDAV, but I’m really not that inclined to, so I decided to use a more portable way to publish my iCal files on the web server, and do it automatically in the background.
I was chatting with James today about the solution that I use that pushes the calendar from this laptop, which I regard as the “master” up to the web server, which runs PHP iCalendar. Of course, I use iSync to synchronise with my mobile phone, and I can make appointments on the phone and they will be imported into iCal at next sync, then to be pushed up onto the web at the next update.
But how to send the file to the web server? Personally I love ssh and especially when I have public key authentication set up properly so I don’t need to type my passwords, so I thought that it would seem sensible to use scp to push the files – I already have a hole in the university firewall for ssh into the box, so it will work from anywhere in the world, even without using VPN to connect to the University network.
So I dusted off my slightly rusty Perl skills and started lookiing at the files that iCal produces. I should probably explain that I used Sunbird for a while, but it was just too buggy to be used as a day-to-day application, so I switched to iCal.
So I now have a perl script which runs from my crontab every 15 minutes, and finds the title of the iCal file from inside the file, because iCal uses a unique name for each file, which is not very user friendly. It then compares each file title with a list of calendars to upload to the server and uses scp to copy the file onto the web server.
It’s currently pretty messy, still has a load of commented out debug code, and really needs a tidy up and a little more intelligence adding, but it works, and works well.
You can’t just copy this into a directory and run it – you really have to understand Perl to be able to customise it for your own use, but please feel free to use it as a starting point for your own development, and if you find it useful, please drop me a line.
You can find the perl program file, and my example data file in this directory.