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