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

Hi, How can I run a perl/cgi script from html form. I tried
<FORM ACTION="C:\test.cgi" METHOD=POST>
But this will not run 'test.cgi'.

Thanks in advance

Replies are listed 'Best First'.
Re: HTML form
by gellyfish (Monsignor) on Mar 14, 2005 at 12:31 UTC

    This is correct. To use the CGI protocol you need to have a web server. If you have IIS installed on your PC and you are using ActivePerl the install of ActivePerl should have configured IIS to run files with a '.pl' suffix as CGI programs from the default web site.

    /J\

      You may also need to make sure that you're telling your browser to connect through the webserver -- There is a big difference between file:///script and http://localhost/script. No matter what my previous company's 'communications' group would like to believe, the default protocol for all communications is not http, and you should not assume that people/programs/whatever will automatically insert it.

      (as well as I remember from my windows days, specifying c:\script will assume file:///, which is a disk read from the local system, and will not get interpreted by the webserver, which may cause it to be parsed/executed/whatever.)

Re: HTML form
by chas (Priest) on Mar 14, 2005 at 13:20 UTC
    In addition to what has already been noted, the script has to be executable by the web user, permissions for actions to be performed by the script have to be appropriate (e.g. if files are to be written to, they have to be writable by the web user), and finally, the cgi script usually has to be in some appropriate directory (such as .../cgi-bin) which is recognized by the web server. (You didn't say what OS or web server (if any) you are using.) Errors in the HTML can also sometimes cause a problem, although it is more likely to be one of the previous mentioned. You should also be sure your script will run from the command line.
    chas
Re: HTML form
by gube (Parson) on Mar 14, 2005 at 14:12 UTC

    you have tried in html is correct but with in cgi form you must ensure did you refer the path. If you getting Internal server error. You just properly install cgi module into your system. and in header perl file give this

    #!C:\Perl5.8.4\bin\perl5.8.4.exe # perl installed exe path use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

    And install those modules before you try and see what is error showing in the browser. Before see it in browser you run as like perl file. If no error in that you may proceed the above procedure.

    Regards,
    Gube