Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch Job Question

Status
Not open for further replies.

markettm

MIS
Aug 16, 2000
71
0
0
US
Hi all, I'm sure this will probably be an easy one for someone.

I've got 300+ servers and want to create a spreadsheet that will list the server's name in one column and it's IP address in another.

I know I can run ping servername -n 1 > c:\filename.txt to get a rough format. But I don't seem to be able to clean it up in Word or Excel to get me the format I'm looking for.

Does anyone have any suggestions for a batch and/or a utility that can automate this for me? Thanks in advance!


-Mike Markett
 
Hi,

You can create this simple bacth file named : nameip.cmd

:: usage :
:: nameip <computername>
ping -n 1 %1 | findstr /i reply > .\reply.txt
for /f &quot;tokens=3 &quot; %%i in (.\reply.txt) do echo %%i > .\reply2.txt
for /f &quot;delims=: tokens=1&quot; %%i in (.\reply2.txt) do echo %1 %%i >> rslt.txt

You'll get the result in your current dir in rslt.txt (servername @ip)

Franck
 
Thanks for the suggestion Franck. However, I'm not sure how I'd combine the 300+ servers I have in a list to work in this batch.

Any suggestions?
 
Of course,

You just have to run an other FOR from an another batch file to call nameip.cmd :
for /f &quot;tokens=1&quot; %%i (your300+serverlist.txt) do call nameip %%i

where your300+serverlist.txt is a text file containing the list of all your server - one server per line.

May i write the list for you ? ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top