Create a simple HTML page from Address Book entries

Jun 30, '05 09:42:00AM

Contributed by: jecwobble

This recent hint, and other ideas from its comments, are great ways to convert your Address Book entries into HTML. But if you are like me, your entries are pretty static, i.e. I don't add, remove, or change my list a lot. And when I'm away from home, I usually just need emails and phone numbers. So I wanted one simple page I could FTP to the web space I get from my ISP whenever I want to. So, I wrote this PHP script (I call it mkcontacts) I can run from the command line. It requires the contacts CLI app. Used in conjunction with sitecopy, I have a simple and quick way to create and update a phone/email list.

As usual, copy and paste this code into your favorite text editor, save somewhere in your PATH and then chmod +x filename to make it executable. Remember to install the contacts application first.

It should be self-explanatory, and is mostly commented. There's no -h help; the only parameter I included is -p for previewing the output without writing a file. I'm sure someone could do this in Perl or a shell script, but I like to use PHP when generating HTML. I'm sure it could be adapted for use on a PHP-enabled web server, or as a CGI script. Feel free to do with it as you will. Comments and critiques are welcome.

[robg adds: This worked as expected, and created a nice looking output page (though I tweaked the CSS colors and definitions to match the look of other pages on my family site).]

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050617134955677