bash script to resolve all hostnames in a list

Hi Guys,
I have a list of over 100 domains.
I need to get the A record of each one of them through a bash script.
I also need the same bash script to write the resolve next to FQDN itself...
Meaning, before the script:
cat /home/user/domains.list

Open in new window

will return

and after the script it will return
David SankovskySenior SysAdminAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
I'm curious what you are going to do with them.  I ask because your two examples, and have not just one but many IP addresses.
David SankovskySenior SysAdminAuthor Commented:
You are correct Dave but they are only examples. in my scenario I know for a fact that no one will have more than one resolve, I do however expect some to return nxdomain.

The point is simple I have a plesk server we wish to close that has over 100 FQDNs. We want to close this server, we just need to know which domains still actually point to this server.
Dave BaldwinFixer of ProblemsCommented:
Interesting.  I would have thought that the Plesk software would tell you that.  Or do you know that some have moved to other servers already?
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Dave BaldwinFixer of ProblemsCommented:
I just wrote a PHP script that does the lookup for my own websites.  I can post that if you want.
David SankovskySenior SysAdminAuthor Commented:
Might even be better I could integrate that into one of my management sites...
Dave BaldwinFixer of ProblemsCommented:
This just displays the name and IP, one to a row.  Substitute you domain names but make sure and observe the punctuation.   You could collect them into a variable and save it to a file fairly easily.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

$hostz = array(
	, ""
	, ""
	, ""

foreach($hostz as $value) {
	echo $value." = ";
	$ip = gethostbyname($value);
	echo $ip."<br>";

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David SankovskySenior SysAdminAuthor Commented:
ok, now I just need to make that read from a file.
Thanks a lot :)
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.