Skip to content

Instantly share code, notes, and snippets.

@berkaycagir
Last active August 29, 2015 14:18
Show Gist options
  • Save berkaycagir/26d293936f647bbe3ccb to your computer and use it in GitHub Desktop.
Save berkaycagir/26d293936f647bbe3ccb to your computer and use it in GitHub Desktop.
Whois script which is able to query new TLD's. (Original script from http://blog.zappan.net/2015/01/new-gtlds-and-whois-command/)
#!/bin/sh
if [ -z $1 ]; then
# Check if we passed an argument
echo "Usage : $0 [domain_name.tld]"
exit
else
domain=$1
fi
# Extract the tld from the domain name
tld=`echo $domain | awk -F'.' '{print $NF}'`
# Search which database host is associated to this tld in the IANA whois db
search=`whois .$tld -h whois.iana.org | egrep -e "^whois:" | awk '{print $NF}'`
if [ $tld = "com" ] || [ $tld = "net" ] || [ $tld = "edu" ]; then
# Executing whois for com, net and edu domains
echo "Using $search database for $domain"
whois $domain
elif [ -n "$search" ]; then
# Finally execute the whois
echo "Using $search database for $domain"
whois $domain -h $search
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment