Article
The output from ldapsearch is sent to stdout as LDIF (LDAP Interchange Format). The format is reasonably readable, but not very flexible. In particular, lines longer than 78 characters are split, with the following line starting with a space. In many cases it is necessary to post-process the output to make it more readable. To obtain the output in single line one useful trick is that piping the LDIF through perl will undo the line splitting mentioned above (lines starting with a space are joined to the previous line). Use the following command of perl to undo the splitting.
perl -p00e 's/\r?\n //g'
Here is an example for the above
Default LDAP search:
ldapsearch -b "ou=ag-BDC8DE1582A8FE05, ou=AppliancesContainer, ou=Partition, ou=PartitionsContainer, ou=VCDN_ROOT, ou=accessManagerContainer, o=novell" -s sub -D cn=admin,o=novell" -x -w novell -s base romaAssociation –LLL
Output:
dn: ou=ag-BDC8DE1582A8FE05,ou=AppliancesContainer,ou=Partition,ou=PartitionsCo ntainer,ou=VCDN_Root,ou=accessManagerContainer,o=novell romaAssociation: ou=3f3822a238615338,ou=ApplianceGroupContainer,ou=Partition,o u=PartitionsContainer,ou=VCDN_Root,ou=accessManagerContainer,o=novell#1#romaA pplianceGroup
In the above we can see output is seen in separated lines with each of 78 characters.
LDAP search piping to perl will get output in a single line for the attribute values.
ldapsearch -b "ou=ag-BDC8DE1582A8FE05, ou=AppliancesContainer, ou=Partition, ou=PartitionsContainer, ou=VCDN_ROOT, ou=accessManagerContainer, o=novell" -s sub -D "cn=admin,o=novell" -x -w novell -s base romaAssociation -LLL | perl -p00e 's/\r?\n //g'
dn: ou=ag-BDC8DE1582A8FE05,ou=AppliancesContainer,ou=Partition,ou=PartitionsContainer,ou=VCDN_Root,ou=accessManagerContainer,o=novell romaAssociation: ou=3f3822a238615338,ou=ApplianceGroupContainer,ou=Partition,ou=PartitionsContainer,ou=VCDN_Root,ou=accessManagerContainer,o=novell#1#romaApplianceGroup
The output of above can be directly used as input to other applications because of single line output.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register


1