Cocoa and Objective-C: Up and Running (by me) is now available from O'Reilly.

Free Command Line Tool for AddressBook

I was trying to come up with a small gift to give you guys and gals for the holidays, so I dug through a bunch of folders and found a command line-based tool I quickly put together some time ago called abtool. It looks contacts up in the AddressBook database and displays them on the screen.

In general, you do something like this:

./abtool smith

Which gives you something like this:

Joe Smith         408-555-1212      joe@smith.site
Bob Smith         408-555-2121      bob@smith.site


There might be other tools out there that do this, and the source is arguably more interesting than the tool itself. There's not much code, but it shows how to find contacts in the database using the AddressBook framework and display various bits of information about them. It also shows a basic example of how to read command line arguments in C and convert NSStrings to C strings and vice-versa.

Download abtool and source (58k)

Enjoy!
Design Element
Free Command Line Tool for AddressBook
Posted Dec 25, 2005 — 7 comments below




 

Cesar Tardaguila — Dec 26, 05 633

Thanks for the gift. It will be a good distraction for the holidays.

Adrian — Dec 26, 05 634

Thanks Scott, nice utility! It has given me ideas for more... actually I've slightly modified it, I hope that you don't mind; I've added sorting, and also modified an odd bug in the printPerson function, where an exception would sometimes pop... anyway, you can download it from http://www.kosmaczewski.net/abtool.zip...

Scott Stevenson — Dec 26, 05 635 Scotty the Leopard

You're welcome and encouraged to modify it.

John — Jan 03, 06 640

I've been using contacts for quite some time now. In particular, I use it to convert my AddressBook to SquirrelMail abook.

I would be particularly interested in a version of contacts that allows one to create a person or group record in AddressBook. I could then write a CGI script to add newly created SquirrelMail contacts to AddressBook, as well.

rg — Jan 04, 06 641

Ruby fans may check out: Fixing the AddressBook with Ruby (sean.treadway.info) and ab2vcard (scottstuff.net/blog/)!

Christoph — May 04, 06 1161

Hi Scott! Thanks very much for this comprehensive example. The addressbook integration of my Orange.ch SMS widget is based on it...did some trivial adjustments.

I hope you don't mind. Thanks again!
Thanks for this and many other examples. I've created a Python/PyObjC version of your little utility.




 

Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.




Technorati Profile
Copyright © Scott Stevenson 2004-2008