Register
It is currently Sat Oct 25, 2014 5:54 am

Lookup NAME&email by phonenumber


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Sun Oct 19, 2008 7:04 am   

Joined: Sun Oct 19, 2008 6:57 am
Posts: 1
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 *


Top
 Profile ICQ  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP