I am trying to make an ldif file to update the entries in the directory using this perl script below. This script is not able to get if the xml code goes in to the second line. For example, i am trying to get the complete value for this attribute:
Since code tag goes into second line.My script can't read and search into next line & print.my_attr1:<order>1</order> <code>PxED1</code>
The text is below :#!/usr/bin/perl while (defined($file = readdir BIN)) { if (($file=~m/test.txt/)){ open FILE,$file; my @lines=<FILE>; for $line (@lines){ if ($line=~/cn=/) { print "\n"; print "$line"; print "changetype: modify"."\n"; print "delete: my_attr1"."\n"; } elsif (($line=~/^my_attr1/)&& ($line=~/<order>1<\/ +order>/)){ print "$line"; } } } } close(FILE); closedir(BIN);
Results of script:cn=abc,ou=People,dc=example,dc=com my_attr1:<order>0</order><code>PxED1</code> my_attr1:<order>1</order> <code>PxED1</code> my_attr1:<order>2</order><code>PxED1</code> my_attr1:<order>3/order><code>PxED1</code> uid:abc cn:abc mail:abc1@hotmail.com my_attr2:<site>M1</site> <timestamp>20060301162200.623Z</timestamp> sn:def givenname:abc cn=def,ou=People,dc=example,dc=com my_attr1:<order>1</order> <code>PMxED1</code> uid:def cn:def mail:def@msn.com my_attr2:<site>M1</site> <timestamp>20060301162200.623Z</timestamp> sn:jkl givenname:jkl cn=jkl,ou=People,dc=example,dc=com my_attr1:<order>2</order><code>P1xED1</code> my_attr1:<order>1</order> <code>P1xED1</code> uid:jkl cn:jkl mail:jkl2@hotmail.com my_attr2:<site>M1</site> <timestamp>20060301162200.623Z</timestamp> sn:jkl givenname:jkl cn=mnp,ou=People,dc=example,dc=com my_attr1:<order>1</order><code>PM23xED1</code> uid:mnp cn:mnp mail:mnp@msn.com my_attr2:<site>M123</site> <timestamp>20060301162200.623Z</timestamp> sn:mnp givenname:mnp
Thanks for help Zac$ ./mymakeldif.txt cn=abc,ou=People,dc=example,dc=com changetype: modify delete: my_attr1 my_attr1:<order>1</order> cn=def,ou=People,dc=example,dc=com changetype: modify delete: my_attr1 my_attr1:<order>1</order> cn=jkl,ou=People,dc=example,dc=com changetype: modify delete: my_attr1 my_attr1:<order>1</order> cn=mnp,ou=People,dc=example,dc=com changetype: modify delete: my_attr1 my_attr1:<order>1</order><code>PM23xED1</code>
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |