Skip to content

Instantly share code, notes, and snippets.

@rquigley
Created October 26, 2015 11:51
Show Gist options
  • Save rquigley/8fbcfac487c0b4529cca to your computer and use it in GitHub Desktop.
Save rquigley/8fbcfac487c0b4529cca to your computer and use it in GitHub Desktop.
Whois with lookup against registrar
#!/bin/bash
set -e
set -o pipefail
BIN="/usr/bin/whois"
DOMAIN=$1
echo "Fetching domain's whois server..."
RES=$($BIN $DOMAIN)
SERVER=$(echo "$RES" | grep -i whois\ server: | head -1 | awk '{print $NF'})
if [[ $SERVER ]]; then
echo "Querying whois server '$SERVER'..."
# Avoid rate-limiting
sleep 1
$BIN -h $SERVER $DOMAIN
else
echo "$RES"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment