[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [cobalt-users] WHOIS
- Subject: RE: [cobalt-users] WHOIS
- From: Mark Spieth <mspieth@xxxxxxxxxxxx>
- Date: Mon Feb 28 08:44:57 2000
6.0 redhat. Here is a perl version of whois wich should run on both the
raq2's and the raq3's
#!/usr/bin/perl -w
#
# BW whois
#
# Copyright (c) 1999 William E. Weinman
# http://bw.org/
#
# Designed to work with the new-mangled whois system introduced 1 Dec 1999.
#
# Under the new domain-name regime the whois system is now distributed
# amongst the various domain-police^H^H^H^H^H^H^H^H^H^H registrars, thereby
# requiring that we make at least two separate requests (to two separate
# servers) for each whois record.
#
# This program will first go to the "root" whois server and ask for a
record.
# If found, the root server will tell us where to go get the actual record,
and
# then we go get it.
#
# Additional feature: If this program gets back a list of references instead
# of a single record (as in the case of a record with a domain name for an
# organization name), it will go out one more time and fetch the actual
# record using the bang-handle. This became necessary because the "root"
# whois server doesn't know where to tell you to go for a handle. Messy.
#
# This program is free software. You may modify and distribute it under
# the same terms as perl itself.
#
# version 1.0 -- wew 2 Dec 1999 -- first release
# version 1.1 -- wew 3 Dec 1999
# added --stripheader (by popular demand)
# thanks to Bill Shupp <hostmaster@xxxxxxxxx> for the
concept.
# also -- now prints "Registrar: <host>" line (unless
quiet)
# version 1.2 -- wew 3 Dec 1999
# added new syntax for specifying a host. can now say:
# whois <request>@<host> as a synonym for:
# whois -h <host> <request>
# thanks to Rob Friedman <playerx_@xxxxxxxxxxx> for
suggesting
# this feature.
#
use strict;
use vars qw( $host $quiet $stripheader );
use IO::Socket;
use Getopt::Long;
$host = '';
$quiet = '';
my $banner = "<http://www.shellserve.net/>\n";
my $banner2 = "works with the new-mangled whois system \n";
my $HEADERBOT = q{you agree to abide by this policy};
use constant TRUE => 1;
use constant FALSE => '';
my $default_host = 'whois.internic.net'; # starting point
my $portname = 'whois(43)';
my $protoname = 'tcp';
GetOptions(
"host=s" => \$host,
"stripheader!" => \$stripheader,
"quiet!" => \$quiet
) or usage();
my $domain = shift or usage();
# support for the <request>@<domain> syntax ...
unless ($host) { ($domain, $host) = split /\@/, $domain; }
my @rc = ();
my $subrec = '';
# signon
print $banner unless $quiet;
# first: Go Fishin' at the InterNIC ...
unless($host) {
@rc = whois_fetch($default_host, $domain);
grep { /Whois Server:\s*(.*)/i and $host = $1 } @rc;
print "Not found: $domain.\n" unless $host;
}
# now we know where to look -- let's go get it
if($host) {
@rc = whois_fetch($host, $domain);
grep {/\((.*-DOM)\).*$domain$/i and $subrec = $1 } @rc;
}
# do we have a sub rec? If so, "Fetch!"
if($subrec) {
print "found a reference to $subrec ... requesting full record ...\n"
unless $quiet;
@rc = whois_fetch($host, $subrec);
}
# tell 'em what we found ...
print "Registrar: $host\n" if (@rc && $host && !$quiet);
my $headerflag = ($stripheader && $host =~ /networksolutions.com$/) ? TRUE :
FALSE;
while(@rc) {
my $l = shift @rc;
print $l unless $stripheader && $headerflag;
if($stripheader) {
$headerflag = FALSE if($l =~ /$HEADERBOT/i);
}
}
sub whois_fetch
{
my $host = shift;
my $domain = shift;
my @rc;
my $rs = IO::Socket::INET->new(
PeerAddr => $host,
PeerPort => $portname,
Proto => $protoname
) or die "$host not found\n";
my $IP = $rs->peerhost;
print "connecting to $host [$IP] ... \n" unless $quiet;
$rs->autoflush(1);
$rs->print("$domain\n");
while(<$rs>) {
push @rc, $_;
}
return @rc;
}
sub usage
{
print $banner, $banner2;
print <<USAGE;
usage: whois [options] <request>
or: whois [options] <request>@<host>
options:
--host <host> Hostname of the whois server
-h <host> this is the same as the <request>@<host> form
if not specified will search $default_host
for a "Whois Server:" record
--quiet Don't print any extraneous messages.
-q ... "just the facts, ma'am"
--stripheader Strip off that silly disclaimer from the
-s whois.networksolutions.com server. You've
read it a thousand times already, right?
USAGE
exit;
}
-----Original Message-----
From: victoria.tc.ca [mailto:wz297@xxxxxxxxxxxxxx]
Sent: Monday, February 28, 2000 11:37 AM
To: cobalt-users@xxxxxxxxxxxxxxx
Subject: [cobalt-users] WHOIS
Anyone know where I can get whois from? and what version?
By the way, what version of Redhat Linux is the raq3 running?
Randall
_______________________________________________
cobalt-users mailing list
cobalt-users@xxxxxxxxxxxxxxx
http://list.cobalt.com/mailman/listinfo/cobalt-users