fouttyw has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Ping from HTML
by davorg (Chancellor) on Jan 06, 2003 at 11:53 UTC

    OK. That's interesting. Did you have a question?

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: Ping from HTML
by gjb (Vicar) on Jan 06, 2003 at 12:58 UTC

    This seems like an excellent job for Java, given a recent post here with the title Java is the machine that goes "Ping!".

    Sorry, absolutely off topic and not helpful at all, but I really couldn't resist ;-)

    Given that you need an entry in the syslog, you'll have little choice but server side logic, I'd think. That means writing a simple CGI script. Here's a quick and dirty hack that shows the basic things to do. Cleaning it up is left as an exercise to the reader. Obviously the first thing to change is the $ping_cmd which is right for my Windows box but probably wrong for your machine.

    No syslog entry though since you don't specify what OS this is supposed to run under. Have a look at CGI::Carp error redirection for a possible approach.

    The HTML code to call it for a specific IP address would look like

    <a href="http://www.you.com/cgi-bin/ping.pl?ip=131.133.33.18">131.133. +33.18</a>

    Hope this helps, -gjb-

    Update: As IlyaM points out, there are a number of security holes in this code. I'm not a web programmer (well, not since CGI.pm was invented), so I'd better refrain from answering web related questions. The first problem he mentions is very bad, I wouldn't have done that when I wrote CGI scripts years ago. I'll leave the code as is for educational purposes, but don't use it without heeding IlyaM's advice in the reply below.

        First point++.
        On your second point, I wonder how neccassary it is to escape the output of the command. If someone has modified a system utility it's just as likely they could access the source of the CGI script as well...

        -Lee

        "To be civilized is to deny one's nature."
      Obviously the first thing to change is the $ping_cmd which is right for my Windows box but probably wrong for your machine.

      If you're going to ping machines from a Perl script, why not use Net::Ping instead of an external program?

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

Re: Ping from HTML
by osama (Scribe) on Jan 06, 2003 at 12:12 UTC

    You wold probably want to write a CGI script, Perl is one of the best scripting languages to use in CGI since it has a lot of flexibility and so many features (see CPAN).

    I'm sorry but I don't feel like writing the code for you... if you do write something.. paste it here and we'll be glad to help you