>>>>> "Www" == Www  <[EMAIL PROTECTED]> writes:


Www> Here is the Code:


Www>    #!/usr/bin/perl

Www>    use LWP::UserAgent;

Www>         my $ua = LWP::UserAgent->new(env_proxy => 1,
Www>                                      keep_alive => 1,
Www>                                      timeout => 30,
Www>                                     );

Www>         $request = HTTP::Request->new('HEAD', 'http://www.essenz.com/');
Www>         $r = $ua->request($request);
Www>         %b = %{$r};

Www>         foreach $key (keys(%b))
Www>         {
Www>                 print "$key: $b{$key}\n";
Www>         }

Here is the Much Simpler Code:

    #!/usr/bin/perl

    use LWP::Simple;
    if (defined get "http://www.essenz.com";) {
      print "The server is up\n";
    } else {
      print "The server is down\n";
    }

If you get a 500 error, the response is undef.  If you get
a good page, the response is the content, which is not undef.

Please don't work harder than you need.


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to