Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ratbeard/108854 to your computer and use it in GitHub Desktop.
Save ratbeard/108854 to your computer and use it in GitHub Desktop.
# see http://troy.yort.com/short-fast-micro-whois
# original http://gist.github.com/82956
# 0 if available
# 1 if taken
d () {
# Append ".com" to input if doesn't contain a ".":
domain=$1
if [[ ! $1 =~ \.\w+$ ]]; then
domain=$domain.com
fi
result=`dig -t NS "$domain" | grep -c "ANSWER SECTION"`
# confirm with whois since some registered domains have no
# NS resource record in root servers
if [ "$result" = "0" ]; then
# -n not supported on osx :(
# result=`whois -n "$domain" | grep -c "Registrar: "`
# osx is:
dontknow="???"
fi
# Print result with color, as smiley!
if [ "$result" = "0" ]; then
echo -e '\e[0;32m:)\e[00m'
else
echo -e '\e[0;31m:(\e[00m'
fi
return $result
}
d () {
# see http://troy.yort.com/short-fast-micro-whoisshort-fast-micro-whois
# note: does not handle registered domain without NS records
ruby -e "require 'net/dns/resolver'; available = Net::DNS::Resolver.new.send('$1', 'NS').answer.empty?; puts available ? '0' : '1'"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment