so I have a script that creates couple of txt files. First file output is something like below..
cn=test,ou=something,ou=some,o=org
cn=testa,ou=something,ou=some,o=org
cn=testb,ou=something,ou=some,o=org
second file output is something like below..
usera
userb
userc
Quote:
userdn=`ldapsearch -x -h $server -LLL "(objectclass=person)" dn | grep dn: | cut -d" " -f2 > userdn.txt
for i in $(cat userdn.txt);do
ldapsearch -h $server -p 389 -x -D $admid -w $admpwd -s one -b "$userdn" dn | grep dn: | cut -d" " -f2 | cut -d"=" -f2 | cut -d"," -f1 > user.txt
for i $(cat user.txt);do
echo "$userdn"
done
done
|
when I ran both ldapsearch commands invidually, they work fine. But when I ran script, I got first file correctly but not the second one. It looks like its not reading the first file correctly and not setting the variable ($userdn) value correctly in the second ldapseach command.
I want read first file first line and run the second ldapsearch and continues, then read the second line..and so on.
Could some one help me with this..
Thanks