I'm trying to create a really simple script that tests dns servers and returns the results into a csv file, and it works perfectly, but takes a long time with a large source file of domains.
Is there some way to use pv or awk to create a progress indicator?
#!/bin/bash
# File name of domain list: One FQDN per line in file.
domain_list='domains.txt'
#
# IP address of the nameserver used for lookups:
ns1_ip='1.1.1.1' # Cloudflare
ns2_ip='9.9.9.9' # Quad9
#
# Seconds to wait between lookups:
loop_wait='1'
#
echo "Domain name, $ns1_ip,$ns2_ip" > dns-test-results.csv;
for domain in `cat $domain_list`
do
ip1=`dig @$ns1_ip +short $domain |tail -n1`;
ip2=`dig @$ns2_ip +short $domain |tail -n1`;
echo -en "$domain,$ip1,$ip2\n" >> dns-test-results.csv;
#
done;
3/20
in CLI (use\r
to overwrite)