--- uwhois-0.3.0 Tue Nov 12 02:37:41 2002 +++ uwhois-0.3.1 Tue Nov 12 02:36:22 2002 @@ -1,31 +1,143 @@ #!/bin/sh +echo +# ---------------------------------------------------------------------------- +echo "uWhois 0.31 -- Retrieves universal WHOIS data using whois.thur.de" +echo "Copyright (c) 2002 Thomas Lahn " +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# ---------------------------------------------------------------------------- function help { - echo "uwhois -- Retrieves universal whois data using whois.thur.de" - echo "Copyright (c) 2002 Thomas Lahn " - echo - echo "Usage: uwhois [-m | -l] [domain | IP_address] [...]" - echo - echo "-m Use \`more' to display output (page)" - echo "-l Use \`less' to display output (scrollable)" - echo + echo "Usage: uwhois [-m | -l | -t] [domain | IP_address] [...]" + echo + echo "-m Use \`more' to display output (page)" + echo "-l Use \`less' to display output (scrollable)" + echo "-t Run a test to determine the query method that is used" + echo " (\`whois' or \`telnet') and which of the supporting" + echo " programs are available (\`sed', \`more' and \`less')." + echo "domain, Domain name/IP address or (if \`sed' is available)" + echo "IP_address an URI containing the domain name/an IP address." } +echo "Protected under the terms of the GNU General Public License (GPL)." +echo "See COPYING file or http://www.fsf.org/copyleft/gpl.html for details." +echo "Thanks to Mario Holbe for his support." echo + if [ -z "$1" ]; then - help; exit 255 + help else - if [ "$1" = "-l" ] || [ "$1" = "-m" ]; then - if [ -z "$2" ]; then help; exit 255; fi - if [ "$1" = "-l" ]; then CMD=less; else CMD=more; fi - shift - for host in $*; do - echo $host | sed s/.*@// | telnet whois.thur.de 43 | $CMD - done - else - for host in $*; do - echo $host | sed s/.*@// | telnet whois.thur.de 43 - done - fi + echo -n "checking for whois... " + whois=1 + chk=`which whois 2> /dev/null` + if [ -z "$chk" ]; then + whois=0 + echo "not found" + echo -n "checking for telnet... " + chk=`which telnet 2> /dev/null` + if [ -z "$chk" ]; then + echo "Error: Either \`whois' or \`telnet' is required for a whois query." + echo + exit 255 + else + echo $chk + fi + else + echo $chk + fi + + echo -n "checking for sed... " + sed=1 + chk=`which sed 2> /dev/null` + if [ -z "$chk" ]; then + sed=0 + echo "not found. Sorry, domain name separation is not supported." + else + echo $chk + fi + + echo -n "checking for more... " + more=1 + chk=`which more 2> /dev/null` + if [ -z "$chk" ]; then + more=0 + echo "not found." + else + echo $chk + fi + + echo -n "checking for less... " + less=1 + chk=`which less 2> /dev/null` + if [ -z "$chk" ]; then + less=0 + echo "not found." + else + echo $chk + fi + test "$1" = "-t" && echo && exit 0 + + if [ "$1" = "-l" ]; then + shift + if [ $less -eq 1 ]; then + CMD=less + elif [ $more -eq 1 ]; then + CMD=more + fi + fi + + if [ "$1" = "-m" ]; then + shift + if [ $less -eq 1 ]; then + CMD=less + elif [ $more -eq 1 ]; then + CMD=more + fi + fi + + if [ -z "$1" ]; then + help + exit 255 + fi + + echo + + for host in $*; do + if [ $sed -eq 1 ]; then + host2=`echo $host | sed 's/.*\/\///' | sed 's/www[.]\(.*[.].*\)/\1/' | sed 's/.*@//' | sed 's/\(.*\)\/.*/\1/'` + else + host2=$host + fi + if [ $whois -eq 1 ]; then + if [ -n "$CMD" ]; then + whois -h whois.thur.de $host2 | $CMD + else + whois -h whois.thur.de $host2 + fi + else + if [ -n "$CMD" ]; then + ((echo $host2 | sleep 10) | telnet whois.thur.de 43) | $CMD + else + (echo $host2 | sleep 10) | telnet whois.thur.de 43 + fi + fi + done fi +echo +echo "Note:" +echo "This is a development release of uWhois. This means that it isn't" +echo "supposed to work, so if it does, it is not doing what it is supposed" +echo "to do, and is therefore not working ;-)" echo