Read Hostname and Return IP Address

Dear Experts,

I have a text file on my itanium box which contains list of nearly 1000 hostnames. I do not have the IP Address of them. I want read each entry from the text file and want to do a nslookup to the DNS Server and get the IP Adresses and put them in another file in the format hostname IP Address.

Lets say,

I have abcd.server.com in my text file first line. I want a script which reads this entry and gets the IP Address from DNS and paste in another file as

abcd.server.com 1.1.1.1

the script should then read the next entry in the text file and go until the end of the file and exit.

Thanks in Advance

Assuming that the output of your version of nslookup is similar to those I have access to:

while read host
do
  lookup=${nslookup "$host"}
  printf "%s %s\n" "$host" "${lookup##*Address: }"
done < FILENAME > NEWFILE