2

I'm looking to get computers names from my network, so i decided to use this following script :

   for /L %%N in (1,1,10) do nslookup 132.147.160.%%N
    PAUSE

With this command everything is displaying correctly on the command prompt.

But with this last one not so well :

for /L %%N in (1,1,256) do nslookup 132.147.160.%%N >nslookup.txt
PAUSE

First of all, the command prompt is displaying wrong things (there's a non-desired "1" added and i don't know why):

    C:\Users\Toshiba\Desktop>nslookup 132.147.160.1  1>nslookup.txt

C:\Users\Toshiba\Desktop>nslookup  132.147.160.2  1>nslookup.txt
*** serveur1.mycompany.fr ne parvient pas à trouver 132.147.160.2 : Non-exi
stent domain

C:\Users\Toshiba\Desktop>nslookup  132.147.160.3  1>nslookup.txt
*** serveur1.mycompany.fr ne parvient pas à trouver 132.147.160.3 : Non-exi
stent domain

C:\Users\Toshiba\Desktop>nslookup 132.147.160.4  1>nslookup.txt
*** serveur1.mycompany.fr ne parvient pas à trouver 132.147.160.4 : Non-exi
stent domain
[ ... etc]

And also in nslookup.txt

i've got NO MORE THAN this output :

Serveur :   serveur1.mycompany.fr
Address:  132.147.160.1

Nom :    132.147.160.256
Address:  60.200.60.100

Please, what am i doing wrong ?

Thank you

11
  • What Windows version? And what should -A do? Commented Jul 19, 2013 at 14:19
  • Hello, it's on Windows 8. in "nslookup help" section, "-a" mean " conical list of names and aliases (i just tried to translate this in english). I tried the batch command without the -a, i've got the same weird "1" in the batch command results. Commented Jul 19, 2013 at 14:33
  • your nslookup means Option non valide : A ? Commented Jul 19, 2013 at 14:47
  • In english it means "Invalid option : A", so right now let's say we forget it. With "nslookup" only i am able to get the results that i'm looking for. But when i'm looking to saving the output results in a file it doesn't work, and i get the same error above. Commented Jul 19, 2013 at 14:59
  • But Non-existent domain is not an error, it means, the IP is "empty". Commented Jul 19, 2013 at 15:01

1 Answer 1

2

try this:

@ECHO OFF &SETLOCAL
for /L %%N in (1,1,10) do nslookup 132.147.160.%%N >>nslookup.txt 2>&1
TYPE nslookup.txt

To remove the error messages from nslookup.txt, simply delete 2>&1.

Sign up to request clarification or add additional context in comments.

1 Comment

It works like a charm ! Thank you very much ! I'll take a look on google of the little command that you added. Thanks again and have a nice day ! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.