#!/bin/sh export PATH DISPLAY PATH=/home/hans/bin:/usr/bin:$PATH DISPLAY=":0" FILE="`/usr/bin/evolution-addressbook-export`" cat $FILE | perl -e' use strict; my $line; my $name; my $tel_work_voice; my $tel_work_fax; my $tel_home; my $tel_pager; my $tel_cell; my $tel_voice; my $email; while ( $line = ) { chomp ($line); chop ($line) ; # trailing ^M #BEGIN:VCARD if ( $line eq "BEGIN:VCARD" ) { $name = ""; $tel_work_voice = ""; $tel_work_fax = ""; $tel_home = ""; $tel_pager = ""; $tel_cell = ""; $tel_voice = ""; $email = ""; } #X-EVOLUTION-FILE-AS: if ( $line =~ /^X-EVOLUTION-FILE-AS\:.*/ ) { $line =~ s/^X-EVOLUTION-FILE-AS://g; $name = $line; print $name." "; } #TEL;WORK;VOICE; if ( $line =~ /^TEL;WORK;VOICE:.*/ ) { $line =~ s/^TEL;WORK;VOICE://g; $tel_work_voice = $line; } #TEL;WORK;FAX; if ( $line =~ /^TEL;WORK;FAX:.*/ ) { $line =~ s/^TEL;WORK;FAX://g; $tel_work_fax = $line; } #TEL;HOME; if ( $line =~ /^TEL;HOME:.*/ ) { $line =~ s/^TEL;HOME://g; $tel_home = $line; } #TEL;PAGER; if ( $line =~ /^TEL;PAGER:.*/ ) { $line =~ s/^TEL;PAGER://g; $tel_pager = $line; } #TEL;CELL; if ( $line =~ /^TEL;CELL:.*/ ) { $line =~ s/^TEL;CELL://g; $tel_cell = $line; } #TEL;VOICE; if ( $line =~ /^TEL;VOICE:.*/ ) { $line =~ s/^TEL;VOICE://g; $tel_voice = $line; } #EMAIL;INTERNET; if ( $line =~ /^EMAIL;INTERNET:.*/ ) { $line =~ s/^EMAIL;INTERNET://g; $email = $email.$line; } #EMAIL;QUOTED-PRINTABLE;INTERNET; if ( $line =~ /^EMAIL;QUOTED-PRINTABLE;INTERNET:.*/ ) { $line =~ s/^EMAIL;QUOTED-PRINTABLE;INTERNET://g; $line =~ s/=0A/ /g; #=0A make it a space $email = $email.$line; } #END:VCARD if ( $line eq "END:VCARD" ) { unless ( $tel_work_voice eq "" ) { print "wk=".$tel_work_voice." "; } unless ( $tel_work_fax eq "" ) { print "fx=".$tel_work_fax." "; } unless ( $tel_home eq "" ) { print "hm=".$tel_home." "; } unless ( $tel_pager eq "" ) { print "pg=".$tel_pager." "; } unless ( $tel_cell eq "" ) { print "cel=".$tel_cell." "; } unless ( $tel_voice eq "" ) { print "alt=".$tel_voice." "; } unless ( $email eq "" ) { print $email; } print "\n"; } } ' > /home/hans/bin/data/jpilot.txt exit 0 rm -fr $FILE