#!/bin/sh

#(C) Fredrik Widell (fredrik@widell.net) 2006
#use as you wish, modify as you wish.
#A very simple script that lets you do
#whois to any top-level-domain and not bother
#which whois-server to ask.
#Just run as mywhois.sh domain.somewhere


mywhois() {
        tld=`echo $1 | awk '{
             n=split($0,adr,".")
             printf"%s\n",adr[n]
          }'`
        dom=`echo $1 | awk '{
             n=split($0,adr,".")
             printf"%s.%s\n",adr[n-1],adr[n]
          }'`

        whois -h ${tld}.whois-servers.net $dom
}


mywhois $1

