Hello guys, I would appreciate if someone can help me for this task:
I have a large txt file that contains lots of user ids in different format. I need to run this against a database output ldif file and print to a file whether they exist or not. And if they exist then I need to print their information from the ldif file. I appreciate in advance if anyone can assist.
#!/bin/sh
while read N M
do
case "$N" in
uid: )
echo "$M"
;;
* )
;;
esac
done <ldif
so save that as one script, say, called ldif-uid.sh
then have another which looks for exact lines
#!/bin/sh
M="$1"
while read N
do
if test "$N" = "$M"
then
exit 0
fi
done
exit 1;
then chain them together
./ldif-uid.sh | exact.sh some-uid
and that would tell you if that user exists
then do another while loops round the whole list of users
#!/bin/sh
while read N
do
./ldif-uid.sh | ./exact.sh "$N"
if test "$?" = "0"
then
echo user "$N" exists
else
echo user "$N" does not exist
fi
done <users
while read v2.txt test.ldif
do
case "$v2.txt" in
uid: )
echo "$test.ldif"
;;
* )
;;
esac
done < test.ldif
######################################
#!/bin/sh
# uid2.sh
test.ldif="$1"
while read v2.txt
do
if test "$v2.txt" = "$test.ldif"
then
exit 0
fi
done
exit 1;
#####################################
./uid.sh | uid2.sh next-uid
#####################################
#!/bin/sh
# uid3.sh
while read v2.txt
do
./uid.sh | ./uid2.sh "$v2.txt"
if test "$?" = "0"
then
echo user "$v2.txt" exists
else
echo user "$v2.txt" does not exist
fi
done <users
while read VAR1 VAR2 VAR3 .... VARN
do
..... $VAR1 etc ....
done <FILE
expects FILE to be the filename you want to read
and VAR1 VAR2 etc to be variable names to be used inside the do/done.
The idea of splitting these up into individual scripts is you can test them individually, so running the first script should just print a list of valid userids from the ldap dump.
mmmm if i understood correctly, VAR1, VAR2 .. etc are uid's ....but there are so many of them in a txt file. Is there a way I can get the txt running against the ldif to check all uids ? Thanks much...