<<< Date Index >>>     <<< Thread Index >>>

Re: Adding entries to ldap addressbook



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday, February 27 at 06:40 PM, quoth Nathan Huesken:
>I invoke the script this way:
>macro index,pager a '<shell-escape>~/add2ldap<enter>'
>
>It then asks me for the name and eMail (because they are not given as 
>paramters).
>So far so good, but I wonder if it is possible to automaticly extract name and 
>sender from an eMail and pass them as parameters to add2ldap?

Sure, all you have to do is create a script that will extract those 
details.

If, for example, you have DJB's mess822 package installed, you could 
do something like this:

     #!/bin/bash
     FROM=`822field from`
     if [[ $FROM =~ "<*@*>" ]] ; then
         EMAIL=`sed 's/.*<\([^>]*\)>.*/\1/' <<<"$FROM"`
         NAME=`sed 's/ *\(.*\)  *<.*/\1/' <<<"$FROM"`
     else
         EMAIL="$FROM"
         NAME=""
     fi
     exec add2ldap "$NAME" "$EMAIL"

If you don't have the mess822 package, you can do something similar if 
you have the formail (part of the procmail package) binary handy. The 
equivalent command would be:

     FROM=`formail -c -x From`

~Kyle
- -- 
I have an existential map; it has 'you are here' written all over it.
                                                       -- Steven Wright
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iD8DBQFHxdARBkIOoMqOI14RAtOnAKDXwj+3Sv7YOfQBldKjay83lZcPwACcCMHu
5HpqldpCD1qq9n2qCGEq//4=
=poQT
-----END PGP SIGNATURE-----