Utility/tool to resolve a list of names

  • Thread starter Thread starter Vicente Zamora
  • Start date Start date
V

Vicente Zamora

Does anyone know of a tool or utility that would take in a list of
hostnames and would resolve each one of them to a text file with the IP
addresses? A command line tool would be nice.

I have a list of 500 windows hosts that I need to know their ip
addresses, and typing nslookup, copying and pasting into a spreadsheet
was getting old.

I found a number of utilities that would take in a list of names and
give me all sorts of information about the host (PsInfo from
Sysinternals is one, Dameware is another), but it doesn't give you IP
address.

There are some others that would take in an IP range and resolve them
to hostnames and ping them, then you can export into CSV or text.

Thanks,

Vince
 
Vicente said:
Does anyone know of a tool or utility that would take in a list of
hostnames and would resolve each one of them to a text file with the IP
addresses? A command line tool would be nice.

I have a list of 500 windows hosts that I need to know their ip
addresses, and typing nslookup, copying and pasting into a spreadsheet
was getting old.

I found a number of utilities that would take in a list of names and
give me all sorts of information about the host (PsInfo from
Sysinternals is one, Dameware is another), but it doesn't give you IP
address.

There are some others that would take in an IP range and resolve them
to hostnames and ping them, then you can export into CSV or text.

Thanks,

Vince


Free NMap is a good tool, especially if you don't know all of the names.

Perl can be used to trivially write a program in a few lines to do this
(if you can program at all, or have a programmer.)

As can just using the built-in tools like NSLookup or even Ping to get
the info.

For instance a rough approximation to your request would be:

for /f %a in (names.txt) do ping %a | findstr "Pinging" >>addresses.txt


For the above to work, you would need the names in "names.txt" (one per
line) and you would want to start with no "addresses.txt" file (or an
empty one.)

More advanced versions would strip off the extraneous words and
characters but that is also trivial to do with a text editor and
search and replace.

WARNING: If you make a "batch file" out of the above snippet (rather
than using it directly on the command line manually) then you must
DOUBLE each %-sign in %a (i.e., %%a) -- It's an oddity of batch files
on DOS/Windows.
 
That is a great tip, I'll check it out.

What I ended up doing (I'm not totally done yet) is with a VB script I
found that I could plug in to Excel and do the nslookup from Excel.
It's not pretty (especially when recalculating 500 nslookups), but it
gets the job done.

Here's the VB code
http://www.excelforum.com/showthread.php?threadid=471818
It's also posted on microsoft.public.excel.programming

Then, just so I could keep manipulating the data, I found a formula to
convert the IP address into decimal, and I use that value to sort by ip
address.

http://www.mvps.org/dmcritchie/excel/sorttcp.htm#tcpn

There's tons of macros and vb scripts to sort and IP address list, but
they can only deal with a single column, and I have several columns
listing Hostname, OS, Service Pack, CPU, Memory, etc, etc, and I need
to keep all columns together.

In any case, I'll look into NMap, looks interesting

Thanks a lot,

Vince
 
Vicente said:
That is a great tip, I'll check it out.
What I ended up doing (I'm not totally done yet) is with a VB script I
found that I could plug in to Excel and do the nslookup from Excel.
It's not pretty (especially when recalculating 500 nslookups), but it
gets the job done.

Here's the VB code

It was also very nice on your part (goog Netiquette)
to post your own solutions. This way everyone learns.

Pretty doesn't much matter if you will only run this code
once or on rare occasions. If you plan to use it every day
for years then perhaps cleaning it up is worth SOME effort.

The key to small utilities is to keep them simple so that you
can use them in the future.

Many people are (perhaps) surprised to find that even though
I use Perl a LOT, I also use Excel in conjunction with it.

Excel excels at handling tables of data and quickly sorting
and resorting that data. It makes it easy to dump the data
to tab or comma delimited format -- where the more powerful
programming languages (especially) Perl can manipulate the data,
filter it, or restructure it.

Thanks.
 
Back
Top