Fri 15 Feb 2008
I get several requests for directory data in CSV format. Until openldap has a csv output option, we will use SED to save the day!
ldapsearch -h localhost -b o=mydomain,c=us uid=sbak* mail telephonenumber
dn: GID=0000001,o=mydomain,c=us
telephoneNumber: 1-734-555-0001
mail: sbak@mydomain.com
dn: GID=0000002,o=mydomain,c=us
telephoneNumber: 1-734-555-0002
mail: sbaker@mydomain.com
If we redirected the above date to a file 11.txt we can than run this command to place a comma at the end of every line:
sed -n '1h;2,$H;${g;s/\n/,/g;p}' 11.txt > 22.txt
Next we will use a simple sed to replace the double comma with a newline:
sed 's/,,/\n/g' 22.txt > 33.csv
Lets look at 33.csv to see the finished product:
sbak@fedoraCore:~ $ cat 33.csv
dn: GID=0000001,o=mydomain,c=us,telephoneNumber: 1-734-555-0001,mail: sbak@mydomain.com
dn: GID=0000002,o=mydomain,c=us,telephoneNumber: 1-734-555-0002,mail: sbaker@mydomain.com
Now you can send your managers data that they can open with excel!
March 3rd, 2008 at 7:27 pm
Well, this is a fine piece of work. No idea what I am looking at- but I do appreciate the nifty graphics and color scheme. Bak as always you are going above and beyond the call for these items. One day you will be the guy behind Die Hard 4.
April 11th, 2010 at 10:32 pm
?????????…
????????,???????????. I get several requests for directory data in CSV format…..
April 16th, 2010 at 12:08 am
??????????, ???? ????? ????????…
ArchiCAD 10. ???????? ? ?????????? I get several requests for directory data in CSV format…..
May 4th, 2010 at 5:45 am
?????, ???????? ?????…
????????-??????????? I get several requests for directory data in CSV format…..