I need to create a script that does outputs the results of nslookup -q=ns for multiple websites into a single file. I know how to make it do so for one webiste, it's just "nslookup -q=ns stackoverflow.com". But how do I do this with multiple websites that are listed after each other to a single file?
Asked
Active
Viewed 2.5k times
1 Answers
4
From the command line:
for /F %x in (websites.txt) do nslookup -q=ns %x
Inside a batch file you have to double the percents:
for /F %%x in (websites.txt) do @echo nslookup -q=ns %%x

Camilo Estevez
- 637
- 1
- 8
- 16
-
is there a way to make this less verbose? i.e.
? -
1You can use find to filter the output of the nslookup command like this: for /F %x in (websites.txt) do @echo %x & nslookup -q=ns %x 2>&1|find /c "internet" – Camilo Estevez Jan 23 '17 at 16:51
-
which would print the website and the number of IPv4 addresses found for it. Of course, you can look for other strings in the output to get different results or parse the output using powershell for instance to get exactly what you want. – Camilo Estevez Jan 23 '17 at 17:21