Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

List of Server Names Query for IP

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
0
apatrol50
Asked:
apatrol50
  • 4
  • 3
1 Solution
 
Jan SpringerCommented:
If *nix:

#!/bin/bash

touch <output filename>

cat <input filename> | while read line
 do
   set $line
   host $line >> <output filename>
 done
0
 
apatrol50Author Commented:
Hi Jesper thanks for the reply. I am not a scripter. How do I package the commands you listed? thanks
0
 
Jan SpringerCommented:
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.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
apatrol50Author 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
0
 
Jan SpringerCommented:
What about something along the lines of (for a batch file):

for /f "%a" in (filename.txt) do nslookup "%a"
0
 
apatrol50Author 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
0
 
Jan SpringerCommented:
The filename is whatever.bat.  You run it by typing 'whatever'.

You need to have the input file in the same directory or specify the full path name to the file.

Modify 'MyFilename.txt' and 'Results.txt' to what you would like.

This should work according to all of the batch scripting that I've read:

@echo off
for /F %a in MyFilename.txt do nslookup %a >> Results.txt
0

Featured Post

Lessons on Wi-Fi & Recommendations on KRACK

Simplicity and security can be a difficult  balance for any business to tackle. Join us on December 6th for a look at your company's biggest security gap. We will also address the most recent attack, "KRACK" and provide recommendations on how to secure your Wi-Fi network today!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now