Perhaps all is not gloomy...

Geraint Jones wrote:
> 
> 17/04/01 13:56:29, Mat Bettinson <[EMAIL PROTECTED]> wrote:
> 
> >GJ> Now to the problem I have: I am a Computer Technician for a
> >GJ> college in the UK and the Network Administrator here wants to
> >GJ> write a CGI Ping tool.
> >
> >No. RT hath decreed that there is no use for ICMP in Rebol. So we've
> >had to use other languages for that task.
> >
> >GJ> will another language do it?
> >
> >Certainly.
> 
> Thanks for the response, but since Perl can't use ICMP without being
> logged-in as the root user and it won't work properly with other
> protocols, which CGI language can we use to ping our own server
> periodically where security is an issue? Or is it possible to code
> our own ICMP functions in REBOL or Perl, and if so, how ...
>

What's wrong with ping?  Is there some local security rule?  Can you
run ping from the command line under the same account that the web
server runs as?  If so, I submit the following:

    > cat ping.pl.cgi
    #!/usr/local/bin/perl -w

    use strict;

    my $HOSTNAME = "x.y.z.com";  # name changed to protect my job ;-)

    open (PING, "ping -q -c 5 $HOSTNAME |");
    my @results = <PING>;
    close (PING);

    print <<PAGE;
    <html>
      <head>
        <title>Ping results for $HOSTNAME</title>
      </head>
      <body>
        <h1>Ping results for $HOSTNAME</h1>
        <pre>@results</pre>
      </body>
    </html>
    PAGE

    exit (0);

which I can run to get the following output:

    > ./ping.pl.cgi
    <html>
      <head>
        <title>Ping results for x.y.z.com</title>
      </head>
      <body>
        <h1>Ping results for x.y.z.com</h1>
        <pre>PING x.y.z.com (300.301.302.303) from 300.301.302.303 :
        56(84) bytes of data.
 
     --- x.y.z.com ping statistics ---
     5 packets transmitted, 5 packets received, 0% packet loss
     round-trip min/avg/max = 80.1/97.7/110.1 ms
    </pre>
      </body>
    </html>

(which is actual output, except for the mangling of host name and IP
addresses).

Translating the above into REBOL "is left as an exercise for the
reader"... ;-)

-jn-
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to