iwhois 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. fn boilerplate { cat $* }
  29. case *.dk
  30. machine=whois.dk-hostmaster.dk
  31. fn boilerplate { grep -v '^#' $* }
  32. case *.se
  33. machine=whois.nic-se.se
  34. fn boilerplate { grep -v '^#' $* | uniq }
  35. case *.es
  36. echo no known whois server for .es
  37. exit
  38. case *
  39. machine=whois.internic.net # alternate: whois.networksolutions.com
  40. }
  41. file=/tmp/iwhois$pid
  42. fn sigexit {
  43. rm -f $file
  44. }
  45. echo $person | telnet -nr tcp!$machine!whois > $file
  46. x=`{ sed -n 's/.*Whois Server: (.*)/\1/p' $file }
  47. switch($x){
  48. case ''
  49. ; # e.g., for .ca
  50. case *' '*
  51. echo $0: buggery: $x >[1=2]
  52. exit botch
  53. case *
  54. echo $person | telnet -nr tcp!$x!whois > $file
  55. }
  56. boilerplate $file
  57. rm $file