windows - Trouble saving output contents from a batch script -


i'm looking computers names network, decided use following script :

   /l %%n in (1,1,10) nslookup 132.147.160.%%n     pause 

with command displaying correctly on command prompt.

but last 1 not :

for /l %%n in (1,1,256) nslookup 132.147.160.%%n >nslookup.txt pause 

first of all, command prompt displaying wrong things (there's non-desired "1" added , 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 in nslookup.txt

i've got no more than output :

serveur :   serveur1.mycompany.fr address:  132.147.160.1  nom :    132.147.160.256 address:  60.200.60.100 

please, doing wrong ?

thank you

try this:

@echo off &setlocal /l %%n in (1,1,10) nslookup 132.147.160.%%n >>nslookup.txt 2>&1 type nslookup.txt 

to remove error messages nslookup.txt, delete 2>&1.


Comments