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.