The idea is to query a DNS to check de NS record, if the domain name exist in table, print "Is authoritative" else " Not authoritative"
I don�t know if to use "awk" and "grep" creating a /tmp/file then read ir from there or what...
#!/bin/bash
clear
echo -n "First DNS to query: "
read dns
echo -n "Domain name to check: "
read domain
echo "`dig @$dns $dominio ns`"
if [ #here is my problem# ]
then
echo "DNS for $domain is authoritative"
fi
else
echo " DNS is NOT authoritative for $domain"
The first issue is that he hasn't checked his spelling:
Change dominio to domain to get this to start working a little better.
Second, check syntax of the IF statement. elif, else, and fi. See the man page for bash inbedded if statement.
Third, either use a temporary file to put the output into so you can use your choice of grep/awk to find what you are looking for - if it's found (grep -c will give you the number of times a string was found) then output something, else output something.
clear
echo -n "First DNS to query: "
read dns
echo -n "Domain name to check: "
read domain
$gval=$(dig @$dns $domain ns | grep -c "qr aa rd" )
if (( $gval > 0 ))
then
echo "DNS for $domain is authoritative"
else
echo " DNS is NOT authoritative for $domain"
fi