Using perl to check services

From: Jason Miles (ryder01_at_bellnexxia.net)
Date: 04/06/04


Date: Tue, 6 Apr 2004 12:27:15 -0400

Hi,

I wrote this little script to check to see if our Lotus Notes servers are
running, and from the command line it works fine if I type perl
notescheck.pl

When I invoke the script from a web page I get an error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.

Please contact the server administrator, you@example.com and inform them of
the time the error occurred, and anything you might have done that may have
caused the error.

More information about this error may be available in the server error log.

Here is the script:

#!/usr/bin/perl -w
#use strict;
use IO::Socket;

$hostName = notesserver;
my $host = shift || $hostName;
my $port = shift || 25;
my $sock = new
IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,Proto=>'tcp');
if($sock)
  {
  print "<script>
 alert(\"Server notesserver is running...\");
        history.back();
        </script>";
  exit;
  }
else
  {
  print "<script>
        alert(\"Server notesserver appears to be down...\");
        history.back();
        </script>";
  exit;
  }
close $sock or die "close: $!";

When I run the script from the console (perl notescheck.pl) I get the
following:

<script>
        alert("Server RSLNM02 is running...");
        history.back();
        </script>[root@rts cgi-bin]#
...which tells me the script is running fine.

Heres the code from the web page:

<form action="/cgi-bin/notescheck.pl" method="post">
<input type="submit">

Can anyone tell me why this doesn't work?

Thanks,
Jason



Relevant Pages

  • Re: Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script ... # have to place corresponding `LoadModule' lines at this location so the ...
    (perl.beginners)
  • Re: Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script Runs perfectly fine from the command prompt. ... # This is the main Apache HTTP server configuration file. ... LoadModule actions_module modules/mod_actions.so ...
    (perl.beginners)
  • Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script ... # have to place corresponding `LoadModule' lines at this location so the ...
    (perl.beginners)
  • Re: Regarding a selection for mobile code/scripting language
    ... Client Side scripting, so the server can send script commands to the client. ... I decided they should be scripted and mobile code. ...
    (Vuln-Dev)
  • Re: HTTPSConnection script fails, but only on some servers (long)
    ... (HTTP/CONNECT + switch to HTTPS) ... wget and my python script. ... >>The python script works with server A, ... the problem seems to depend on both the client ...
    (comp.lang.python)