From 64e6e37d79832cb5c5ddad26f00c41bece8196e0 Mon Sep 17 00:00:00 2001 From: rgrosso Date: Mon, 28 Jan 2008 14:01:16 +0000 Subject: [PATCH] Parsing the output of ldapsearch with a perl script to unfold lines and make it compareble to the corresponding ldif file for diff --- SHUTTLE/schema_prod/unfoldlines.pl | 29 +++++++++++++++++++++++++++++ SHUTTLE/schema_prod/verify.sh | 4 +++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 SHUTTLE/schema_prod/unfoldlines.pl diff --git a/SHUTTLE/schema_prod/unfoldlines.pl b/SHUTTLE/schema_prod/unfoldlines.pl new file mode 100755 index 00000000000..ae6d5615a72 --- /dev/null +++ b/SHUTTLE/schema_prod/unfoldlines.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl +# unfoldlines.pl is a script to unfold lines when they start with a leading +# space. It is meant to correct the output of ldapsearch making it comparable +# to the ldif files +# Usage: ldapsearch [...args...] | ./unfoldlines.pl > verify.out +# if verify.out is the file to be diffed against the ldif files +# + +my @lines=<>; + +$folded=0; +$cnt=1; +while ($lines[$cnt]) { + $line = $lines[$cnt]; + if ($line =~ /^ /) { + $folded = 1; + $line =~ s/^ //; + chomp $lines[$cnt-1]; + $line = $lines[$cnt-1] . $line; + print $line; + } else { + if($folded==0) {print $lines[$cnt-1];} + $folded=0; + } + $cnt++; +} + +close(FILE); + diff --git a/SHUTTLE/schema_prod/verify.sh b/SHUTTLE/schema_prod/verify.sh index 4d3a9681350..122fcefe165 100755 --- a/SHUTTLE/schema_prod/verify.sh +++ b/SHUTTLE/schema_prod/verify.sh @@ -27,6 +27,8 @@ case "$1" in esac ldapsearch -H ldap://pcalishuttle01.cern.ch -x -b "$SEARCH,o=shuttle_prod,dc=cern,dc=ch" -L -L -L > verify.out +cat verify.out | ./unfoldlines.pl > verify1.out -diff --ignore-space-change --ignore-blank-lines verify.out $FILE | grep -v "> #" +diff --ignore-space-change --ignore-blank-lines verify1.out $FILE | grep -v "> #" | grep -v '^0[a-z]' +rm verify.out verify1.out -- 2.43.0