1#!/bin/rc 2# iwhois domain - print registration data for domain 3rfork e 4person=`{echo $1|sed s/@.*//} 5fn boilerplate { sed -n '/^[ ]*[A-Za-z][A-Za-z]*:$/,$p' $* } 6 7switch($1){ 8case *@* 9 machine=`{echo $1|sed s/.*@//} 10case *.ca 11 machine=whois.cira.ca 12 fn boilerplate { grep -v ':[ ]*$' $* } 13case *.us 14 machine=whois.nic.us 15 fn boilerplate { sed '/^>* Whois database was last updated on/,$d' $* } 16case *.co.uk *.net.uk *.org.uk 17 machine=whois.nic.uk 18 fn boilerplate { sed '/^ +WHOIS database last updated at/,$d' $* } 19case *.ac.uk 20 machine=whois.ja.net 21case *.au 22 machine=whois.aunic.net 23 fn boilerplate { grep -v ':[ ]*$' $* } 24case *.fr 25 machine=whois.nic.fr 26 fn boilerplate { grep -v '^%%' $* } 27case *.de 28 machine=whois.denic.de 29 person='-T dn '^$person 30 fn boilerplate { cat $* } 31case *.dk 32 machine=whois.dk-hostmaster.dk 33 fn boilerplate { grep -v '^#' $* } 34case *.se 35 machine=whois.nic-se.se 36 fn boilerplate { grep -v '^#' $* | uniq } 37case *.es 38 echo no known whois server for .es 39 exit 40case *.jp 41 machine=whois.jprs.jp 42 person=$person^'/e' 43 fn boilerplate { cat $* } 44case *.in 45 machine=whois.inregistry.net 46 fn boilerplate { cat $* } 47case *.cn 48 machine=whois.cnnic.net.cn 49 fn boilerplate { cat $* } 50case [0-9]*.[0-9]*.[0-9]*.[0-9]* 51 machine=whois.arin.net 52 fn boilerplate { cat $* } 53case * 54 machine=whois.internic.net # alternate: whois.networksolutions.com 55 fn boilerplate { cat $* } 56} 57file=/tmp/iwhois$pid 58fn sigexit { 59 rm -f $file 60} 61echo $person | telnet -nr tcp!$machine!whois > $file 62x=`{ sed -n ' 63 s/.*Whois Server: (.*)/\1/p 64 s;.*ReferralServer: whois://(.*);\1;p 65 ' $file } 66switch($x){ 67case '' 68 ; # e.g., for .ca 69case *' '* 70 echo $0: buggery: $x >[1=2] 71 exit botch 72case * 73 # chase the referral chain 74 echo $person | telnet -nr tcp!$x!whois > $file 75} 76boilerplate $file 77rm $file 78