Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

multiple whois queries

Posted on 2003-03-17
7
Medium Priority
?
188 Views
Last Modified: 2010-05-18
I would like to build a program which will be able to ask internic for a whois then ask the autoritive registrar's whois server for information and loop it 50 times (max).  I have been using a command line program which works very well except for the occasional "Can't print to server" error.  I hve three questions:
1.  Is there a way to keep a channel open for multiple queries?
2.  How does one keep the program working after such an error?
3.  Using the following script how does one change the whois server dynamically?

my $out=whois($host);

print $out;

sub whois {
   my $sock = IO::Socket::INET->new(
   PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net'),
   PeerPort => 'whois(43)',
   Proto    => 'tcp',
   Timeout  => 60) or die "IO::Socket::INET: $!";

   $sock->print($_[0],"\r\n");
   my @result=$sock->getlines;
   $sock->close;
   return wantarray?@result:join('',@result);
}

Thanks for your help.
0
Comment
Question by:blenkhn
  • 3
  • 3
7 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 8158161
0
 
LVL 1

Expert Comment

by:Trevize
ID: 8162972
1. No, the WHOIS protocol doesn't have this possibility.

2. Automatic retry:

my $out;
for (1..10)
{
   eval
   {
      $out = whois($host);
   };

   last unless $@;  # stop trying if successful

   sleep(1);        # wait 1 seconds before next try
}

if (defined $out)
{
   print $out;
}
else
{
   print STDERR "Could not retrieve domain information";
}

3. Do you mean this:

out = whois($host, "whois.something.net");
0
 

Author Comment

by:blenkhn
ID: 8167164
Thanks for your reply,

With using the statement

out = whois($host, "whois.something.net");

do I still need to have the statement

 PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net').

How do I change the script to do this?

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:Trevize
ID: 8168836
You don't need to change anything - either you set the whois server explicitly when calling the whois() function or it uses the default server (whois.publicinterestregistry.net).
0
 

Author Comment

by:blenkhn
ID: 8171182
Thanks for your reply,

With using the statement

out = whois($host, "whois.something.net");

do I still need to have the statement

 PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net').

How do I change the script to do this?

0
 
LVL 1

Accepted Solution

by:
Trevize earned 375 total points
ID: 8173816
You don't need to change anything - either you set the whois server explicitly when calling the whois() function or it uses the default server (whois.publicinterestregistry.net).
0
 

Author Comment

by:blenkhn
ID: 8281390
I have used your suggestion to cancel out the errors occuring from the whois server.  what about transmission errors?  maybe a timer to rehit the server after so long? How would one check to see if the complete record has been received?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question