iwhois 1.6 KB

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