Address book searching on the Mac

| No Comments | No TrackBacks
I don't want to keep manually syncing my address book on Vodafone with that of my mac, so I use this script to pull out the phone numbers of people when I want to send them a text message using webtext (or my webtext script).
#!/bin/sh

search_for=name
return_val=phone

args=$(getopt s:r: $*)

set -- $args

while :; do
    case $1 in
        -s) search_for=$2; shift;;
        -r) return_val=$2; shift;;
        --) shift; break;;
    esac
    shift
done

if [ $# -lt 1 ]; then
    echo 1>&2 "usage: $(basename $0) -s <search> -r <return> YOUR_SEARCH"
    exit 127
fi

search=
for i in $@; do
    if [[ -z $search ]]; then
        search="($search_for contains \"$i\")"
    else
        search="$search and ($search_for contains \"$i\")"
    fi
done

scriptcode="tell app \"Address Book\" to get (value of $return_val) of every person where $search"

osascript -s "s" -e "$scriptcode"

exit 0


You can get it Here.

No TrackBacks

TrackBack URL: http://www.petesh.com/scgi-bin/MT/mt-tb.cgi/206

Leave a comment

About this Entry

This page contains a single entry by Pete Shanahan published on July 31, 2008 8:08 PM.

Go see 'The Dark Knight' was the previous entry in this blog.

This entry is brought to you by intrepid ibex is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.