This is a first try in BASH to get the Callers/Faxers Name out of the addressbook by givving the name just like capisuite provides it.
There is much to do though! Please comment any suggestions!
Code:
#!/bin/bash
# p2n.sh Phonenumber to Name
# usage: p2n.sh <areacode><phonenumber> Just as it comes from capisuite
# p2n.sh - Copyright (C) 2008 Ralph Müller-Welt <ralph@mueller-welt.net>
# ToDos:
# Make it look through a single file containing all vcards
# Other Backends like LDAP?
searchnr=$1
vcardsource=/media/Elements/kdepim/addressbook/
if [ -d $vcardsource ]
then
cd $vcardsource
fi
for file in * # Traverse all the files in current directory.
do
unset fname
unset email
while read line
do
if [[ $line =~ "BEGIN:VCARD" ]]
then
isvcard=true
elif [[ $line =~ "END:VCARD" ]]
then
isvcard=false
elif [[ $line =~ "FN:" ]] && $isvcard
then
fname=${line/#"FN:"/""}
elif [[ $line =~ "EMAIL;TYPE=PREF:" ]] && $isvcard
then
email=${line/#"EMAIL;TYPE=PREF:"/""}
elif [[ $line =~ "TEL;TYPE=" ]] && $isvcard
then
if [[ ${line//[^[:digit:]]/} == $searchnr ]]
then
echo $fname
echo $email
exit 0
fi
fi
done < $file # while read line
done # for file in *