Skip to content

Instantly share code, notes, and snippets.

@troy
Created March 21, 2009 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save troy/82956 to your computer and use it in GitHub Desktop.
Save troy/82956 to your computer and use it in GitHub Desktop.
.bashrc 1-character whois. Bash function to check domain name availability; type one character, get one character.
d () {
# see http://troy.yort.com/short-fast-micro-whois
result=`dig -t NS "$1" | grep -c "ANSWER SECTION"`
if [ "$result" = "0" ]; then
# some registered domains have no NS resource record in root servers; may
# be false negative, so confirm with whois
result=`whois -n "$1" | grep -c "Registrar: "`
fi
echo $result
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