Skip to content

Instantly share code, notes, and snippets.

@peterc
Created February 8, 2014 15:57
Show Gist options
  • Save peterc/8885824 to your computer and use it in GitHub Desktop.
Save peterc/8885824 to your computer and use it in GitHub Desktop.
Domain and Twitter availability checker
#!/bin/bash
# domainavailable
# Fast, domain name checker to use from the shell
# Use globs for real fun:
# domainavailable blah{1..3}.{com,net,org,co.uk}
# Inspired by foca / giles:
# http://gilesbowkett.blogspot.com/2009/02/simple-bash-domain-availability.html
trap 'exit 1' INT TERM EXIT
for d in $@;
do
if host $d | grep "NXDOMAIN" >&/dev/null; then
if whois $d | grep -E "(No match for|NOT FOUND)" >&/dev/null; then
echo "$d AVAILABLE";
else
echo "$d taken";
fi
else
echo "$d taken";
fi
if curl -s "https://twitter.com/users/username_available?suggest=1&full_name=&email=&suggest_on_username=true&context=front&custom=1&username=${d%.*}" | grep "available" >&/dev/null; then
echo "@${d%.*} AVAILABLE";
else
echo "@${d%.*} taken";
fi
sleep 0.1;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment