[4315] in WWW Security List Archive
Re: Simple socket Perl script needed...
daemon@ATHENA.MIT.EDU (Steff Watkins)
Mon Feb 10 05:26:11 1997
Date: Mon, 10 Feb 1997 08:41:25 +0000 (GMT)
From: Steff Watkins <Steff.Watkins@Bristol.ac.uk>
To: www-security@ns2.rutgers.edu
In-Reply-To: <s2fb17ad.007@novell.com>
Errors-To: owner-www-security@ns2.rutgers.edu
On Fri, 7 Feb 1997, Harris Demel wrote:
> Before I commit suicide, does anyone have a small Perl script that simply
> opens a socket to a web server and does a GET? Either Perl or C source
> code would work for me...
>
> Thanks in advance to whomever makes my day.
Hello Harris,
it is really easy... if you have Perl 5 AND the LWP module installed
(LWP available from any CPAN mirror).
Once installed, it is a simple case of having the following script..
#!/bin/perl
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$server="IP.Details.of.your.server.here";
$req = new HTTP::Request 'GET' => "$server";
$req->header('Accept' => 'text/html');
$res = $ua->request($req);
if ($res->is_success)
{
print("Hey! $server is alive and working!!!\n");
}
The LWP module (really useful for Web working) handles all the webserver
calling and interfacing. I use a modified version of this script to ping
the local webservers (there's seven of them) that my department look
after about once every half an hour to make sure that they are still
functioning.
Anyway, hope that helps,
Steff
: Steff Watkins, General Computer-type being
: University of Bristol, Clifton, Bristol, BS8 1TH, UK
:
: RFC-822 : Steff.Watkins@bris.ac.uk
: X-400 : /G=Steff/S=Watkins/O=Bristol/PRMD=UK.AC/ADMD= /C=GB/
: Phone: +44 177 9287869 (external) 3046 / 7869 (internal)