marto9 has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone. I made a script for updating ip ranges. It all works fine. But I get an error at some time when the script is running. So it doesn't happen immediately. The error that I get is: "No valid response for 4th time... dying.... at C:\OTHERS\Ranges\update.pl line 23". I've searched on google, but I can't find anything about it. I hope you can help me out here.
#!usr/bin/perl use Net::Whois::IP qw(whoisip_query); use Net::Whois::RIPE; use LWP::UserAgent; use HTTP::Request; $ua = new LWP::UserAgent; $ua->timeout(5); $ua->agent("Mozilla/6.0"); $url = "http://10.5.5.5/update.php"; $req = HTTP::Request->new('GET',$url); $req->authorization_basic('admin','pass'); $res = $ua->request($req); $content = $res->content; @tetn1 = split(/<br>/,$content); %seen1 = (); %seen2 = (); open(OUTPUT,">>updated.txt"); foreach $line1 (@tetn1) { next unless $line1 and not $seen1{$line1}++; @stuff = split(/-/,$line1); $stuff[0] =~ s/^\s+|\s+$//g; #ip $stuff[1] =~ s/^\s+|\s+$//g; $response = whoisip_query($stuff[0]); #line with the error foreach (sort keys(%{$response}) ) { $output = $_.":".$response->{$_}; if ($output =~ /^netname/i) { @netname = split(/:/,$output); $netname[1] =~ s/^\s+|\s+$//g; next unless $output and not $seen2{$netname[1]}++; if ($output =~ /^netname/) { $whois = Net::Whois::RIPE->new("whois.ripe.net"); foreach $inet ($whois->query($netname[1])) { $outputripe = $inet->inetnum; next unless $outputripe; @lines = split(/-/, $outputripe); $lines[0] =~ s/^\s+|\s+$//g; $lines[1] =~ s/^\s+|\s+$//g; print OUTPUT $lines[0]."-".$lines[1].\n"; } } } elsif ($output =~ /^NetRange/) { @netnameus = split(/:|-/,$output); $netnameus[1] =~ s/^\s+|\s+$//g; $netnameus[2] =~ s/^\s+|\s+$//g; print OUTPUT $netnameus[1]."-".$netnameus[2]."\n"; } } } close(OUTPUT); exit;

Replies are listed 'Best First'.
Re: Whois query error: "No valid response for 4th time..."
by marto (Cardinal) on Aug 15, 2008 at 10:55 UTC
    Really, you searched google? What are you searching for exactly? A search for your 'unknown error' "No valid response for 4th time" points to the module Net::Whois::IP, which oddly enough, you are using. While it is important to learn how to use search engines properly, it is also important to read the code and documentation of the modules you are using.

    I suggest you read the code of Net::Whois::IP, which suggests you are not getting a valid response from the registrar.

    Also, use strict; and use warnings; and basic error checking seem to be missing from your code.

    Update: typo s/strinct/strict/ thanks jettero, note to self, never attempt posting on no sleep and zero caffeine.

    Update 2: print OUTPUT $lines[0]."-".$lines[1].\n"; should be print OUTPUT $lines[0]."-".$lines[1]."\n";

    Hope this helps

    Martin
    A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.