I start to use BBDB with VM and was looking for a utility to get my pine
 addressbook into the bbdb database. Since I could not find anything
googling and looking through the mailing lists, I came up with a
somewhat simple but reasonably functional awk script. For it to work
.addressbook has to be massaged somewhat with awk and sed. Here is the
script:

$ awk -v RS="\n   " -v ORS="" '{print}' .addressbook | sed -e 's/"//g'
-e 's/)//g' -e 's/(//g' | awk -f pine2bbdb.awk > .bbdb

The first awk part joins the strange .addressbook line breaks within a
record. That is a \n and 3 spaces. The sed gets rid of quotes and
parentheses which .bbdb would not like. pine2bbdb.awk follows for copy
and paste:

#(c) Andreas Plesch 2003, feel free to use and distribute
BEGIN{
# pine uses tabs to delimit
  FS = "\t"
    print ";;; file-version: 6"
# two new info-fields are introduced to preserve data
    print ";;; user-fields: (pine-fcc pine-nick pine-comments)"}
{
nick = $1
name = $2
address = $3
fcc = $4
comments = $5
# name handling, with and without comma
  if (name ~ ",") {
    split (name, sname, ",")
    firstname = substr(sname[2],2)
    lastname = sname[1]
  }
  else {
    l = split(name, sname, " ")
    lastname = sname[l]
    firstname = substr(name, 1, length(name)-length(lastname)-1)
  }
  time = strftime("%F")
# deal with multiple email addresses which are mailing lists in pine
  n = split(address, saddress, ",")
# each address gets an entry with the same mail-alias
# does not deal with addresses which are other aliases
  for (i in saddress){
  print "[\""firstname"\" \""lastname"\" nil nil nil nil
(\""saddress[i]"\") ((notes . \"from\
 pine\") (pine-fcc . \""fcc"\") (pine-nick . \""nick"\") (pine-comments\
. \""comments"\") (creation-date . \""time"\") (time-stamp\
. \""time"\") (mail-alias . \""nick"\")) nil]"
  }}

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dr. A. Plesch     Harvard University
Dep. of Earth and Planetary Sciences
20 Oxford St.     Cambridge

__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/
  • (no subject) 杭州杭诚专利事务所
    • (no subject) Plesch Andreas

Reply via email to