nslookup and for command?

  • Thread starter Thread starter res0jhe2
  • Start date Start date
R

res0jhe2

C:\appdev\dns>nslookup
Default Server: myserver.home.com
Address: 10.29.2.104

-snip-

I can feed a computername using for with the following syntax:

C:\appdev\dns>for /f "tokens=1" %a in (machine.dat) do @nslookup %a
Server: myserver.home.com
Address: 10.29.2.104

*** myserver.home.com can't find machine2082w: Non-existent domain
Server: myserver.home.com
Address: 10.29.2.104

*** myserver.home.com can't find machine2202w: Non-existent domain
Server: myserver.home.com
Address: 10.29.2.104

*** myserver.home.com can't find machine2379w: Non-existent domain
Server: myserver.home.com
Address: 10.29.2.104

Name: machine03269.home.com
Address: 10.29.16.107

-snip-
the text file machine.dat looks like:

fzrvew2082w
fzrvew2202w
fzrvew2379w
fzrvew03269w

-snip-

The type of output I want would be as follows:

macine03269w 10.29.16.107
anothermachine 10.x.x.x
nextmachine 10.x.x.x....

Could anyone help with the syntax to get this output?

Thx,
 
not excatly sure what you are asking but does this work

cd (the directory where your machine.dat file is)
for /f "tokens=1" %a in (machine.dat) do @nslookup %a
 
Hello, res0jhe2:
On Fri, 04 Mar 2005 15:04:30 GMT: you wrote...

r> The type of output I want would be as follows:
r>
r> macine03269w 10.29.16.107
r> anothermachine 10.x.x.x
r> nextmachine 10.x.x.x....

@echo off & setlocal enabledelayedexpansion
for /f %%x in (machine.dat) do (
for /f "tokens=*" %%y in ('nslookup.exe -type=A %%x 2^>NUL^| find
"Address:"') do set ip=%%y
set ip=!ip:Address:=!
set ip=!ip: =!
echo %%x !ip!
)

Regards, Paul R. Sadowski [MVP].
 
Back
Top