#! /bin/sh : # # awhois - all-encompassing whois client wrapper.... # # (c) Copyright 1998 Greg A. Woods. # Freely redistibutable. # All other rights reserved. # Return all fixes/modifications to . # #ident "@(#)LOCAL:awhois.sh 1.18 98/07/16 11:10:51 (woods)" #ident "@(#)awhois:$Name$:$Id$" argv0=`basename $0` DEFAULTWHOISHOST="whois.internic.net" USAGE="Usage: $argv0 [-h whois-host] query-string" HELP="$USAGE -h host query the specified host. The appropriate whois server will be chosen based on the query-string given, so long as it is recognized as a handle, host, domain, network, AS number, etc. If the query-string doesn't match an appropriate pattern the default server ($DEFAULTWHOISHOST) will be queried. " WHOISHOST="" while getopts "h:H" OPTCHAR ; do case $OPTCHAR in h) WHOISHOST=$OPTARG ;; H) echo "$HELP" 1>&2 exit 2 ;; \?) echo "$USAGE" 1>&2 exit 2 ;; esac done shift `expr $OPTIND - 1` # so far as I know all whois servers are case-insensitive.... # XXX this invocation of tr should work for SysV & BSD & POSIX # QUERY=`echo "$*" | tr '[A-Z]' '[a-z]'` if [ -n "$WHOISHOST" ] ; then exec whois -h $WHOISHOST "$QUERY" fi # XXX there's lots of info about how to use the RIPE database # XXX more effectively at: # XXX http://www.ripe.net/docs/ripe-157.html#toc18 case "$QUERY" in # mostly derived from "whois -h whois.arin.net European" 62.*|163.12[89].*|163.1[3][0-9].*|163.14[0-3].*|164.40.*|171.1[6-9].*|171.2[0-9].*|171.3[0-3].*|192.162.*|192.16[4-7].*|19[3-5].*) exec whois -h whois.ripe.net "$QUERY" ;; # mostly derived from "whois -h whois.arin.net Asia" 61.*|169.20[89].*|169.21[0-9].*|169.22[0-3].*|20[23].*|21[01].*) exec whois -h whois.apnic.net "$QUERY" ;; # This is a bit of a quick&dirty hack. # ARIN's info for this (under NETBLK-SEED-NETS) says: 192.72.3.0 - 192.72.252.0 192.72.*) exec whois -h whois.iii.org.tw "$QUERY" ;; # the rest of the IP numbers, ARIN handle patterns, ... # (net handles, netblk handles, and AS numbers, come at the end) [1-9].*|[1-9][0-9].*|[12][0-9][0-9].*|[0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9]|*-arin) exec whois -h whois.arin.net "$QUERY" ;; *.com|*.org|*.edu|*.net|*-dom|*-org) exec whois -h whois.internic.net "$QUERY" ;; *.gov) exec whois -h whois.nic.gov "$QUERY" ;; *.mil) exec whois -h whois.nic.mil "$QUERY" ;; *.at) exec whois -h whois.univie.ac.at "$QUERY" ;; *.au) exec whois -h whois.aunic.net "$QUERY" ;; *.ca) exec whois -h whois.cdnnet.ca "$QUERY" ;; *.ch) exec whois -h whois.nic.ch "$QUERY" ;; *.de) exec whois -h whois.nic.de "$QUERY" ;; *.fr) exec whois -h whois.nic.fr "$QUERY" ;; *.il) exec whois -h whois.ripe.net "$QUERY" ;; *.it) exec whois -h whois.nic.it "$QUERY" ;; *.jp) exec whois -h whois.nic.ad.jp "$QUERY/e" ;; *.kr) exec whois -h whois.krnic.net "$QUERY" ;; *.li) exec whois -h whois.nic.li "$QUERY" ;; *.mx) exec whois -h nic.mx "$QUERY" ;; *.nl) exec whois -h www.domain-registry.nl "$QUERY" ;; *.pk) exec whois -h whois.pknic.net.pk "$QUERY" ;; *.se) exec whois -h whois.sunet.se "$QUERY" ;; *.sg) exec whois -h whois.nic.net.sg "$QUERY" ;; *.th) exec whois -h whois.thnic.net "$QUERY" ;; *.com.tw) exec whois -h whois.iii.org.tw "$QUERY" ;; *.tw) exec whois -h whois.twnic.net "$QUERY" ;; *.ac.uk) exec whois -h whois.ja.net "$QUERY" ;; *.co.uk|*.org.uk|*.net.uk|*.plc.uk|*.gov.uk|*.net.uk) exec whois -h whois.nic.uk "$QUERY" ;; *.us) exec whois -h whois.isi.edu "$QUERY" ;; # must come last to avoid kacking net-foo.com, etc.... net-*|netblk-*|asn-*) exec whois -h whois.arin.net "$QUERY" ;; # catch-all.... [a-z][a-z][0-9]*|[a-z][a-z][a-z][0-9]*) exec whois -h whois.internic.net "$QUERY" ;; esac echo "Warning: '$argv0' knows not which whois server to talk to for '$QUERY'." 1>&2 exec whois -h $DEFAULTWHOISHOST "$QUERY" .