#!/bin/sh - ############################################################## # whoiss, wrapper for jwhois # # Performs lookups for any number of domains, netblocks, handles, IPs, ... # on a single command line, without specifying TLD servers. # # Available From: # http://www.roble.com/docs/whoiss # Thanks To: # Troy Bowman, Kare Presttun, and Tom Coradeschi for their contributions. # See Also: # # # # # No Thanks To: # Network Solutions (as Verisign) for originally corrupting the root whois servers. # # # # # # ############################################################## # $Id: whoiss,v 1.96 2009/11/05 14:28:08 root Exp root $ ############################################################## ## this script inspired and extends jwhois, www.gnu.org/software/jwhois set -a BINARY="jwhois -f" ## TBD #BINARY="jwhois -n" MINPAGELENGTH=0 ## use a file viewer (default=less) for more than $MINPAGELENGTH queries PATH=/usr/local/bin:/bin:/opt/sfw/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb _POSIX2_VERSION=199209 LANG=C if [ "$1" = "" ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then echo " USAGE: `basename $0` [domain[ip] [name@domain] [...]" exit 0 fi BINARY_BIN=`echo $BINARY | awk '{ print $1 }'` which $BINARY_BIN >/dev/null 2>&1 if [ $? != 0 ]; then echo " ERROR: $BINARY_BIN not found" exit fi barheader () { echo "==========[ $1 ]================================================================" | \ awk -F"\/\/" '{ printf "%-.75s", $1 }' 2>/dev/null } run_query () { barheader "$query" echo "" ##### using jwhois as of v1.87 ##### # $BINARY -h $whois $query $BINARY $query echo "" barheader "abuse.net contact for $query" echo "" $BINARY -h whois.abuse.net $query } ## parse out invalid delimiters ## for query in `echo $* | sed -e 's/\[/ /g' -e 's/(/ /g'` ; do ## check for URLs or email addresses ## query="`echo ${query} | sed -e 's/^.*@//' -e 's,^.*//,,' -e 's/^www\.//' \ -e 's/:.*$//' -e 's,/.*$,,'`" if [ "$DOMTEST" != "$TLD" ]; then query=${DOMTEST} elif [ "$query" = "." ]; then continue fi if [ $# -gt "$MINPAGELENGTH" ]; then ## find a decent file viewer ## if [ -x /bin/less ]; then PAGER="/bin/less -ceinx4" elif [ -x /usr/bin/less ]; then PAGER="/usr/bin/less -ceinx4" elif [ -x /usr/local/bin/less ]; then PAGER="/usr/local/bin/less -ceinx4" else PAGER=${PAGER:-more} fi run_query $query | $PAGER else run_query $query ## to stdout ## fi done