It should look like :-
dn: cn=bob,cn=user,dc=com
objectclass: inetOrgPerson
objectclass: ePerson
objectclass: organizationalPerson
objectclass: person
objectclass: top
cn: bob
sn: bob
userpassword: password
uid: bob
dn: cn=john,cn=user,dc=com
objectclass: inetOrgPerson
objectclass: ePerson
objectclass: organizationalPerson
objectclass: person
objectclass: top
cn: john
sn: john
userpassword: password
uid: john
etc
I have been thinking that this may not be such a good way of doing this. I think maybe it would be better to have one input file containing the dn's and then just write a new file from the script.
What is the best way to read in a file, process it line by line and write out a new file please (bear in my mind I don't know shell scripting very well) ?
e.g.
while read line
do
print "$line" >> $outfile
print "objectclass: inetOrgPerson" >> $outfile
print " objectclass: ePerson" >> $outfile
print "objectclass: organizationalPerson" >> $outfile
print "objectclass: person" >> $outfile
print "objectclass: top" >> $outfile
print "cn: john" >> $outfile
print "sn: john" >> $outfile
print "userpassword: password" >> $outfile
print "uid: john" >> $outfile
done < $filename
I am sure the above syntax is wrong .. can someone tell me the best way to do something like that ?
Going one step further, if my input file contained the dn and additional info, e.g. :-
# dn, firstname, surname, password
cn=bob,cn=user,dc=com, bob, jones, Password123
cn=john,cn=user,dc=com, john, smith, Password456
how could I read each line into the script but put dn, firstname, surname and password into separate variables and ignore comments ??
Many thanks