--- uwhois-0.3.1 Tue Nov 12 02:36:22 2002 +++ uwhois-0.3.2 Tue Nov 12 02:36:57 2002 @@ -1,7 +1,7 @@ #!/bin/sh echo # ---------------------------------------------------------------------------- -echo "uWhois 0.31 -- Retrieves universal WHOIS data using whois.thur.de" +echo "uWhois 0.3.2 -- 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 @@ -15,31 +15,56 @@ # 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. +# along with this program (COPYING file); if not, write to the Free +# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# This is work in progress. Feel free to submit suggestions and report any bugs. +# # ---------------------------------------------------------------------------- function help { - echo "Usage: uwhois [-m | -l | -t] [domain | IP_address] [...]" + echo "Usage: `basename $0` [-c COMMAND | -mlptv?] OBJECT [...]" 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 "-c, --command Try to use COMMAND to display output which must read from" + echo " standard input." + echo "-m, --more Try to use \`more' to display output (page by page)." + echo "-l, --less Try to use \`less' to display output (scrollable)." + echo " --vi Try to use \`vi' to display output (scrollable and editable)." + echo "-p, --pager Try to use the command from the PAGER environment variable" + echo -n " (currently " + if [ -n "$PAGER" ]; then + echo -n "\`$PAGER'" + else + echo -n "undefined" + fi + echo ") to display output." + echo " Note that the first command must read from standard input." + echo "-t, --test Run a test to determine the query method that is used" + echo " (\`whois' or \`telnet') and which of the supporting" + echo " programs are available." + echo "-v, --verbose For future use. Verbose mode is always enabled for now." + echo " --version Display version and exit." + echo "-?, --help Display this help and exit." + echo "OBJECT Domain name or IP address or (if \`sed' is available)" + echo " an URI containing the domain name/an IP address." + echo " Two or more OBJECTs are separated by spaces." } 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 "This is work in progress. Feel free to submit suggestions and report any bugs." echo -if [ -z "$1" ]; then +if [ -z "$1" ] || [ "$1" = "-?" ] || [ "$1" = "--help" ]; then help else - echo -n "checking for whois... " + if [ "$1" = "-v" ] || [ "$1" = "--verbose" ]; then + shift + echo "Verbose mode is always enabled for now. Continuing as if \`-v' was not used." + fi + if [ "$1" = "--version" ]; then exit 0; fi + + echo -n "checking for whois... " whois=1 chk=`which whois 2> /dev/null` if [ -z "$chk" ]; then @@ -58,7 +83,7 @@ echo $chk fi - echo -n "checking for sed... " + echo -n "checking for sed... " sed=1 chk=`which sed 2> /dev/null` if [ -z "$chk" ]; then @@ -68,7 +93,7 @@ echo $chk fi - echo -n "checking for more... " + echo -n "checking for more... " more=1 chk=`which more 2> /dev/null` if [ -z "$chk" ]; then @@ -78,7 +103,7 @@ echo $chk fi - echo -n "checking for less... " + echo -n "checking for less... " less=1 chk=`which less 2> /dev/null` if [ -z "$chk" ]; then @@ -87,57 +112,153 @@ else echo $chk fi - test "$1" = "-t" && echo && exit 0 - if [ "$1" = "-l" ]; then + echo -n "checking for vi... " + vi=1 + chk=`which vi 2> /dev/null` + if [ -z "$chk" ]; then + vi=0 + echo "not found." + else + echo $chk + fi + + echo -n "checking for \$PAGER... " + pager=1 + if [ -n "$PAGER" ]; then + for i in "$PAGER"; do + chk=`which $i 2> /dev/null` + if [ -z "$chk" ]; then + pager=0 + echo "not found." + else + echo $chk + fi + break + done + else + echo "undefined." + fi + + echo + test "$1" = "-t" -o "$1" = "--test" && exit 0 + + if [ "$1" = "-c" ] || [ "$1" = "--command" ]; then shift - if [ $less -eq 1 ]; then + if [ -n "$1" ]; then + for i in "$1"; do + CMD1=$i + break + done + echo -n "checking for $CMD1... " + command=1 + chk=`which $CMD1 2> /dev/null` + if [ -z "$chk" ]; then + command=0 + echo "not found." + else + CMD=$1 + shift + echo $chk + fi + else + echo "CMD missing." + fi + if [ -z "$CMD" ]; then + if [ $pager -eq 1 ]; then + CMD=$PAGER + elif [ $vi -eq 1 ]; then + CMD="vi -" + elif [ $less -eq 1 ]; then + CMD=less + elif [ $more -eq 1 ]; then + CMD=more + fi + fi + fi + + if [ "$1" = "-p" ] || [ "$1" = "--pager" ]; then + shift + if [ $pager -eq 1 ]; then + CMD=$PAGER + elif [ $vi -eq 1 ]; then + CMD="vi -" + elif [ $less -eq 1 ]; then CMD=less elif [ $more -eq 1 ]; then CMD=more fi fi - if [ "$1" = "-m" ]; then + if [ "$1" = "--vi" ]; then + shift + if [ $vi -eq 1 ]; then + CMD="vi -" + elif [ $more -eq 1 ]; then + CMD=more + elif [ $less -eq 1 ]; then + CMD=less + elif [ $pager -eq 1 ]; then + CMD=$PAGER + fi + fi + + if [ "$1" = "-l" ] || [ "$1" = "--less" ]; then shift if [ $less -eq 1 ]; then CMD=less elif [ $more -eq 1 ]; then CMD=more + elif [ $vi -eq 1 ]; then + CMD="vi -" + elif [ $pager -eq 1 ]; then + CMD=$PAGER fi fi - if [ -z "$1" ]; then - help - exit 255 + if [ "$1" = "-m" ] || [ "$1" = "--more" ]; then + shift + if [ $more -eq 1 ]; then + CMD=more + elif [ $less -eq 1 ]; then + CMD=less + elif [ $vi -eq 1 ]; then + CMD="vi -" + elif [ $pager -eq 1 ]; then + CMD=$PAGER + fi fi - echo + if [ -z "$1" ]; then + echo "OBJECT missing." + help + else + 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 + for host in $*; do + if [ $sed -eq 1 ]; then + host2=`echo $host | sed 's/.*\/\///' | sed 's/www[.]\(.*[.].*\)/\1/' | sed 's/.*@//' | sed 's/\(.*\)\/.*/\1/'` else - whois -h whois.thur.de $host2 + host2=$host fi - else - if [ -n "$CMD" ]; then - ((echo $host2 | sleep 10) | telnet whois.thur.de 43) | $CMD + 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 - (echo $host2 | sleep 10) | telnet whois.thur.de 43 + 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 - fi - done + done + fi 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 "-- " +echo "Note: This is a development release of uWhois. This means that it" +echo " isn't supposed to work, so if it does, it is not doing what" +echo " it is supposed to do, and is therefore not working ;-)" echo