Skip to content

Instantly share code, notes, and snippets.

@rquigley
Created October 26, 2015 11:51
Show Gist options
  • Select an option

  • Save rquigley/8fbcfac487c0b4529cca to your computer and use it in GitHub Desktop.

Select an option

Save rquigley/8fbcfac487c0b4529cca to your computer and use it in GitHub Desktop.

Revisions

  1. rquigley created this gist Oct 26, 2015.
    21 changes: 21 additions & 0 deletions whois.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/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