nslookup and for command?

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,
 
G

Guest

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
 
P

Paul R. Sadowski [MVP]

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].
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Unable to use "NSLOOKUP" command effectively 1
nslookup error 3
nslookup error 2
nslookup? 1
NSLOOKUP 5
NSLOOKUP DNS Issue 3
nslookup issue 6
nslookup 4

Top