Necessity maybe the mother of invention, but some times little 'side' projects can keep you from going crazy under tight deadlines. I've been beating my body silly the last two weeks to put together a e-commerce solution for one of my clients. Today was 'very' mentally draining with the 'final-final' review, edits, tweaks and 'oh-my-gawd-we-forgot-to...' going on.

During this 'hectic' time, I forced myself a few minutes here and there to divert my brain from the stress and wrote the following script. Believe it or not, the exercise really helped me stay focused on the important work.

Anyhoo - to make a long story longer, I was a little pissed off about the changes to rs.internic.net and the new 'limited' whois results. So I wrote the following Perl script to query rs.internic.net using the standard *NIX whois executable, capture the info - and if the domain existed, snag the whois server name from the info presented and offer you the option to query the responsible registrar for more detail on the domain.

I think its pretty slick. There might be a better way to do some of the things in the script, but output was more important than code elegance. Enjoy. Feedback is appreciated. Cut out the code between the demarcations below and watch out for line wrap. Save to a text file called 'ewhois' and place in your /home/username/bin directory. chmod to 755. To use, type 'ewhois domain.tld'. Note: I've found that there are some very handy extensions to the new internic whois (not mine). You can enter no extension (e.g. 'whois domain') and it will search all of the .com, .edu, .org and .net extensions for you - giving you a hit list of 'registered' domains. Also if you include no extension, but just the trailing '.' (e.g. 'whois domain.') it give you a hit list of all domains that _begin_ with the word entered.

#!/usr/bin/perl

##

## eWhois, an extended Whois Program

##

## Version .9b

## CopyLeft KeyBoard Jockeys, 1999

## www.keyboardjockeys.com

## eWhois@keyboardjockeys.com

## This program is NOT web browser safe!!

## There is no checking for 'funny' stuff.

## Do not use via a browser on an unsecure page.

## Just give the address you want

## to ewhois and if it exists in

## the rs.internic.net database,

## you'll be given the option to

## extend the search to the regitry

## who holds the source of the whois info

## edit the $varWhoisExe for your server

## put in your /home/username/bin directory

## chmod to 755

## usage: ewhois foo.edu

## ewhois foo.

## ewhois foo

## Edit this variable for your whois program

## Note some linux versions alias whois for fwhois

$varWhoisExe = "/usr/bin/fwhois";

# $varWhoisExe = "/usr/bin/whois";

## Setting target of whois

$varWhoisTarget = lc($ARGV[0]);

## If no arguments passed to program show help

if ($varWhoisTarget) {

print "Processing...

";

$varWhoisExe .= " " . $varWhoisTarget;

$varWhoisResultOne = `$varWhoisExe`;

print $varWhoisResultOne;

$varIndex = index(lc($varWhoisResultOne),"whois server:");

if ($varIndex > -1) {

$varIndex1 = index(lc($varWhoisResultOne),"whois\.");

$varIndex2 = index(lc($varWhoisResultOne),"\.",($varIndex1+7));

$varLength = ($varIndex2 + 4) - $varIndex1;

$varWhoisServer = substr($varWhoisResultOne,$varIndex1,$varLength);

$varWhoisExe .= "\@" . $varWhoisServer;

print "Query " . $varWhoisServer . " for more info on " . $varWhoisTarget . "? (y\/n) ";

chop($varAnswer=<STDIN>);

if (lc($varAnswer) eq "y") {

print "

Processing...

";

$varWhoisResultTwo = `$varWhoisExe`;

print $varWhoisResultTwo;

}

}

} else {

print "

usage: ewhois domain.tld

ewhois domain.

ewhois domain

";

}

exit;