LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help with bash script for DNS (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-bash-script-for-dns-4175649562/)

symudy 03-05-2019 07:54 AM

Help with bash script for DNS
 
Hello guys,

How could i make bash script to filter this DNS Resolver
https://public-dns.info/nameservers.txt

because it came out with false positive results

So the idea is could it be as following code
Code:

#!/bin/sh
for IP in `cat ./resolvers.txt`;
do
        printf "%-4s", $IP
        dig @$IP test.com;
       
done


scasey 03-05-2019 10:30 AM

It's not at all clear what you're expecting to accomplish.
What do you mean by false positive?

test.com is a real domain name...it should give a positive response.

Honest Abe 03-20-2019 07:44 AM

@OP, use a while loop and try again. For loop could spew garbage if empty white spaces exists in your file.

Code:

cat FILE |while read line
do
<what u wanna do>
done

And of course, provide outputs. One user's garbage is one admin's treasure. :)

berndbausch 03-20-2019 09:02 AM

Quote:

Originally Posted by Honest Abe (Post 5975806)
Code:

cat FILE |while read line
do
<what u wanna do>
done


Cat abuse alert. Better:
Code:

while read line
do
<what u wanna do>
done < FILE


Honest Abe 03-20-2019 09:12 AM

:) yes, that too.


All times are GMT -5. The time now is 08:31 PM.