-
-
Save ratbeard/108854 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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