Paul Bijnens <[EMAIL PROTECTED]> writes:

> On 2006-04-10 16:08, J.Slee wrote:
> > I have just been thinking about that, but I am looking at doing this
> > for
> > about 20 - 30 sites and modifying the hosts file and probably doing a
> > flush of the DNS cache between each check is a little heavy handed.  I
> > was rather hoping there was some method in the LWP module to direct the
> > GET request to a specific IP address, rather than letting it work it out
> > for itself from the supplied URL.
> 
> And more low level using Net::HTTP:
> 
> use Net::HTTP;
> foreach $ip ("192.168.0.100", "192.168.0.101") {
>          my $s = Net::HTTP->new(Host => $ip);
>          $s->write_request(
>               GET => "http://myhostsite.domain/mypage";,
>               # Other options if needed
>               );
>          my ($code, $mess, %h) = $s->read_response_headers;
>          print "Host: ", $s->host, " answered with code $code\n";
> }

This out to work as well (untested):

#!/usr/bin/perl -w
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
foreach $ip ("192.168.0.100", "192.168.0.101") {
        my $res = $ua->get("http://$ip/mypage";, Host => "myhostsite.domain");
        print "Host: $ip answered with code ", $res->code, "\n";
}

Regards,
Gisle

Reply via email to