iwhois 1.8 KB

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