Code:
#!/bin/bash
# by Crouse -- Visit Bashscripts.org
# dnc - Domain Name Checker
# Created 08-01-2006
# Created for my own personal use. I do not guarantee the accuracy of results
# obtained through the use of this program.
if [ -z "$1" ] ; then
echo " ";
echo " ######### COMMAND FAILED ########## ";
echo " USAGE: $0 domainnamenoextension";
echo " EXAMPLE: $0 bashscripts";
echo " In the example the bashscripts domain name is checked for";
echo " availability. bashcripts.com, bashscripts.net, bashscripts.org, bashscripts.us are all checked.";
echo " ######### COMMAND FAILED ########## ";echo " "; exit
fi
echo ""
echo "======== DNC Started ========";echo ""
domainname=$1
declare -a tld
# You can put other tld extensions into the array, just remember to
# add more numbers to the "num" section for every new tld extension.... next num needed as shown would be 4.
tld=(.com .net .org .us .info)
for num in 0 1 2 3
do
digdomain="$domainname${tld[num]}"
dig $digdomain | grep "QUERY: 1, ANSWER: 0," &>/dev/null
if [ $? -ne 0 ]; then
echo "$digdomain is registered"
else
whois =$digdomain | grep -i "Updated Date" &>/dev/null
if [ $? -eq 0 ]; then
echo "$digdomain is registered"
else
echo -ne "$digdomain is " ;tput smso; echo "AVAILABLE"; tput rmso;
fi
fi
done
echo "";echo "======== DNC Finished ========";echo ""
exit