2

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?

1 Answer 1

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

3
  • is there a way to make this less verbose? i.e. <website> <any IP response yes/no>?
    – ffghfgh
    Commented Jan 19, 2017 at 19:59
  • 1
    You 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" Commented Jan 23, 2017 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. Commented Jan 23, 2017 at 17:21

Your Answer

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