input -output file

Hi,

I am having an Input file .which is having a list of names.
comapring with our database , needs to write the out put in file called output.txt , format should be name--> country--->phone number

could you please help me..
thanks in advance

database?? you mean oracle ,DB etc...
if so how you want to compare please eloberate..

yes, it is a database DB...
like this===> ldapsearch -h ldap uid="$user" uid eriMasterDomain ou eriCountry | \
egrep "^ou=|^eriMasterDomain=|^uid=|^eriCountry=" | \

If we provide an input file (.txt) containing two fields - name and region (e.g jon, Asia)
You need to read this file and for each name hit LDAP. From the returned values you need to pick up the field eriCountry which contains the country information and provide an output file (txt) of the type - jon,Asia,INDIA

what have you tried till now??

Here is the code:

for record in `cat users1.txt`
do

user=`echo $record | awk -F, '{print $1}'`

ldapsearch -h ldap uid="$user" uid eriMasterDomain ou eriCountry | \
egrep "^ou=|^eriMasterDomain=|^uid=|^eriCountry=" | \
nawk 'BEGIN{ORS="";DoCR=0}{DoCR=DoCR+1;if((DoCR % 4)==0){print $1"\n"}else{print $1"|"}}'

done

it is reading from users1.txt.

how can I write the out put to a file (txt)

thanks..

Exactly i dont knw wht u r trying for.

if nawk gives you the final output ,.. then you just redirect the output to a file by using >>.

Hi

here is my program..

=========

for record in `cat eamcs.txt`
do

user=`echo $record | awk -F, '{print $1}'`

ldapsearch -h ldap uid="$user" uid ou eriMasterDomain eriCountry | \
egrep "^ou=|^eriMasterDomain=|^uid=|^eriCountry=" | \
nawk 'BEGIN{ORS="";DoCR=0}{DoCR=DoCR+1;if((DoCR % 4)==0){print $1 "\n"}else{prin
t $1 " "}}' >> output.txt
done

================

here is my input

ERTCHWE
ERTSYWU
ERTKESU
ERTSEYU
ERTWSY
EILRAAL

===========
out put is coming like this..

uid=ERTCHWE | eriMasterDomain=EAPAC | eriCountry=Taiwan, | ou=ERT
uid=ERTSYWU | eriCountry=Taiwan, | ou=ERT | uid=ERTKESU | eriMasterDomain=EAPAC
| eriCountry=Taiwan, | ou=ERT
uid=ERTSEYU | ou=ERT |uid=ERTWSY | eriMasterDomain=EAPAC | eriCountry=Taiwan, | ou=ERT
uid=EILRAAL | eriMasterDomain=EAPAC | eriCountry=India | ou=EIL

But, I want like this=====>

uid=ERTCHWE | eriMasterDomain=EAPAC | eriCountry=Taiwan, | ou=ERT
uid=ERTSYWU | eriCountry=Taiwan, | ou=ERT
uid=ERTKESU | eriMasterDomain=EAPAC| eriCountry=Taiwan, | ou=ERT
uid=ERTSEYU | ou=ERT
uid=ERTWSY | eriMasterDomain=EAPAC | eriCountry=Taiwan, | ou=ERT
uid=EILRAAL | eriMasterDomain=EAPAC | eriCountry=India | ou=EIL

=======

thanks in advance..

-----Post Update-----

Hi friends,

the problem is in line....
nawk 'BEGIN{ORS="";DoCR=0}{DoCR=DoCR+1;if((DoCR % 4)==0){print $1 "\n"}else{prin
t $1 " "}}' >> output.txt

here it counts upto 4 ,if it is less then it writes..

could you please correct as it has to check uid..if uid fails, thencome out of loop...
am I right ?

thanks

-----Post Update-----

Hi friends,

the problem is in line....
nawk 'BEGIN{ORS="";DoCR=0}{DoCR=DoCR+1;if((DoCR % 4)==0){print $1 "\n"}else{prin
t $1 " "}}' >> output.txt

here it counts upto 4 ,if it is less then it writes..

could you please correct as it has to check uid..if uid fails, thencome out of loop...
am I right ?

thanks