Reputation: 23
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
Upvotes: 2
Views: 377
Reputation: 37589
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
.
Upvotes: 2