We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

List of Server Names Query for IP

apatrol50
apatrol50 asked
on
Medium Priority
343 Views
Last Modified: 2012-05-07
I have a list of approxiamately 300 servers names in an excel spreadsheet that I copied to a test file (one servername per line). I need to run a command or utility that will give me the IP of each server. NSlookup doesnt apear to have a file import function and many of the port scanners only take list of ip to resolve to name. Any ideas?

thanks
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
If *nix:

#!/bin/bash

touch <output filename>

cat <input filename> | while read line
 do
   set $line
   host $line >> <output filename>
 done

Author

Commented:
Hi Jesper thanks for the reply. I am not a scripter. How do I package the commands you listed? thanks
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
Do you have a linux/solaris/hpux/tru64 operating system?  I am not familiar with windows batch commands.

Your other option would be to upload the domain names, I'll run it and upload the results.

Author

Commented:
No we are all windows and the servers are not public so youwouldnt be able to run the script for me... thanks for the help though
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
What about something along the lines of (for a batch file):

for /f "%a" in (filename.txt) do nslookup "%a"

Author

Commented:
Hey Jesper how would you make this statement into a batch? If i save it in a text file and change the exension to .bat and run in a cmd prompt i get an error at the "for" statement
CERTIFIED EXPERT
Most Valuable Expert 2015
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.