-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathldif2mxab.awk
66 lines (60 loc) · 1.4 KB
/
ldif2mxab.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
BEGIN {FS=":"; print "#RS1.1"}
/^sn:/ {lname=$2}
/^givenName:/ {fname=$2}
/^cn:/ {dname=$2}
/^mail:/ {email=$2}
/^homePhone:/ {hphone=$2}
/^mozillaHomeStreet:/ {home2=$2; if (home2=="") {cmd ="echo" $3 "|base64 -di |recode u8..l1"; cmd | getline home2; close(cmd) }}
/^mozillaHomeLocalityName:/ {hcity=$2; if (hcity=="") {cmd ="echo" $3 "|base64 -di |recode u8..l1"; cmd | getline hcity; close(cmd) } }
/^mozillaHomePostalCode:/ {hzip=$2}
/^mozillaHomeCountryName:/ {hcountry=$2}
/^mail:/ {email1=$2}
/^telephoneNumber:/ {wphone=$2}
/^street:/ {work2=$2}
/^l:/ {wcity=$2}
/^o:/ {org=$2}
/^ou:/{dept=$2}
/^mozillaHomeUrl:/ {www1=$2":"$3}
/^$/ {
if (dname=="") {dname=lname" "fname};
printf("%s\n",dname);
printf("%s\n",wphone);
printf("%s\n",hphone);
printf("%s %s\n",dept,org);
printf("%s %s %s %s %s %s\n",work,work2,wzip,wcity,wstate,wcountry);
printf("%s %s %s %s %s %s\n",home,home2,hzip,hcity,hstate,hcountry);
printf("%s\n",email1);
printf("%s\n",fax);
printf("%s\n",strftime());
printf ("Pager: %s\n",pager);
printf ("Cell Phone: %s\n",cell);
printf ("Skype : %s\n",sname);
printf ("Web: %s %s \n",www1,www2);
print "#RE";
dname=""
lname=""
fname=""
wphone=""
hphone=""
dept=""
org=""
work=""
work2=""
wcity=""
wstate=""
wzip=""
wcountry=""
home=""
home2=""
hcity=""
hstate=""
hzip=""
hcountry=""
email1=""
fax=""
pager=""
cell=""
sname=""
www1=""
www2=""
}