#!/usr/local/bin/perl -w # # whois(1) for ppt Thursday, June 24, 1999 # Casey Tweten crt@highvision.com # # Switches emulate current BSD whois(1) # Added -6g from Yiorgos Adamopoulos script ########################################### use strict; $|++; use IO::Socket; &usage if ( !@ARGV || $ARGV[0] eq '-?' ); my $eol = "\015\012"; my $crlf = $eol x 2; my %whois = ( '-i' => 'whois.internic.net', '-a' => 'whois.arin.net', '-d' => 'whois.nic.mil', '-p' => 'whois.apnic.net', '-r' => 'whois.ripe.net', '-g' => 'whois.nic.gov', '-6' => 'whois.6bone.net', ); my $option = $ARGV[0] =~ /^-/ ? shift : '-i'; my $host; if ( exists $whois{$option} ) { $host = $whois{$option}; } elsif ( $option eq '-h' && $ARGV[1] ) { $host = shift; } else { $host = $whois{'-i'}; } my $whois = new IO::Socket::INET(PeerAddr => $host, PeerPort => 43, Proto => 'tcp', Timeout => 30, ) || die "Couldn't open connection to $host: $!"; my $query = 'whois '; $query .= ( @ARGV > 1 ? join(/ /, @ARGV ) : $ARGV[0] ) if $ARGV[0]; $query .= $crlf; print $whois $query; $whois->autoflush(1); print while <$whois>; close $whois; ############################################################################ sub usage { print <<__EOF__; WHOIS(1) OpenBSD Reference Manual - Edited for Perl implementations WHOIS(1) NAME $0 - Internet domain name and network number directory service SYNOPSIS $0 [-iadprg6] [-\?] [-h host] name [...] DESCRIPTION whois looks up records in the databases maintained by several Network In- formation Centers (NICs). The options are as follows: -i Use the InterNIC Registry, this is also the default. -a Use the American Registry for Internet Numbers (ARIN) database. It contains network numbers used in those parts of the world cov- ered neither by APNIC nor by RIPE. -d Use the (US Military) Defense Data Network (DDN) database. It contains points of contact for subdomains of .MIL. -p Use the Asia/Pacific Network Information Center (APNIC) database. It contains network numbers used in East Asia, Australia, New Zealand, and the Pacific islands. -r Use the R'eseaux IP Europ'eens (RIPE) database. It contains net- work numbers and domain contact information for Europe. -g Use the Government-Wide Registration Service. A whois interface for finding domains ending in .GOV and .FED.US -6 Use the 6bone registry that is developed, maintained and operated by David Kessens of Qwest. -h host Use the specified host instead of the default NIC (whois.inter- nic.net). Either a host name or an IP address may be specified. -\? View the usage of $0 The operands specified to whois are concatenated together (separated by white-space) and presented to the whois server. The default action, unless directed otherwise with a special name, is to do a very broad search, looking for matches to name in all types of records and most fields (name, nicknames, hostname, net address, etc.) in the database. For more information as to what name operands have special meaning, and how to guide the search, use the special name ``help''. SEE ALSO RFC 812: Nicname/Whois __EOF__ exit } ##usage ############################################################################ __END__ =pod =head1 NAME whois -- Internet domain name and network number directory service =head1 SYNOPSIS whois [-iadprg6] [-\?] [-h host] name [...] =head1 DESCRIPTION whois looks up records in the databases maintained by several Network Information Centers (NICs). =head2 OPTIONS The options are as follows: =over =item B<-i> Use the InterNIC Registry, this is also the default. =item B<-a> Use the American Registry for Internet Numbers (ARIN) database. It contains network numbers used in those parts of the world covered neither by APNIC nor by RIPE. =item B<-d> Use the (US Military) Defense Data Network (DDN) database. It contains points of contact for subdomains of .MIL. =item B<-p> Use the Asia/Pacific Network Information Center (APNIC) database. It contains network numbers used in East Asia, Australia, New Zealand, and the Pacific islands. =item B<-r> Use the R'eseaux IP Europ'eens (RIPE) database. It contains net- work numbers and domain contact information for Europe. =item B<-g> Use the Government-Wide Registration Service. A whois interface for finding domains ending in .GOV and .FED.US =item B<-6> Use the 6bone registry that is developed, maintained and operated by David Kessens of Qwest. =item B<-h> I Use the specified host instead of the default NIC (whois.internic.net). Either a host name or an IP address may be specified. =item B<-\?> View the usage of I. =back =head1 ENVIRONMENT The working of B is not influenced by any environment variables. =head1 BUGS I has no known bugs, however I am sure there may be. =for html
<joke> This is 100% certified virus and bug free code. </joke>
=head1 REVISION HISTORY $Log: whois.tweton,v $ Revision 1.3 2004/08/05 14:24:41 cwest cleanup, new version number on website Revision 1.1 2004/07/23 20:10:21 cwest initial import Revision 1.0 1999/03/04 15:19:03 Casey Tweten Initial revision =head1 AUTHOR The Perl implementation of I was written by Casey Tweten, I. =head1 COPYRIGHT and LICENSE This program is copyright by Casey Tweten 1999. This program is free and open software. You may use, modify, distribute and sell this program (and any modified variants) in any way you wish, provided you do not restrict others to do the same. =cut