Re: CGI Question
by gulden (Monk) on Jul 20, 2009 at 17:23 UTC
|
You need to configure Apache to handle that files.
The following AddHandler directive tells the server to treat all files with the cgi or pl extension as CGI programs:
AddHandler cgi-script cgi pl
After putting your CGI running read about mod_perl for better performance.
«A contentious debate is always associated with a lack of valid arguments.»
| [reply] [Watch: Dir/Any] [d/l] |
|
Hey
Thank you for the quick reply. i checked the httpd.conf file and surel
+y enough the "Addhandler" was commented out. i added ur option and th
+en tunrned on CGI in the options directive. I restarted Apache and th
+en launched the browser. now it gives me an internal server error pro
+blem. i went into the apache logs and this is the error it shows
"The system cannot find the file specified. : couldn't spawn child p
+rocess: C:/Documents and Settings/Maddy17/My Documents/mywebsite/env.
+cgi"
Now i went back to the document root dir and checked if the file was p
+resent. the file exists there so i am not sure what to do now.
Thanks | [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] |
|
|
Could you run the cgi on the cmd line?
c:> my_cgi.pl
Make sure the path to perl is correct.
#!"C:\path\to\perl"
| [reply] [Watch: Dir/Any] [d/l] [select] |
Re: CGI Question
by CountZero (Bishop) on Jul 20, 2009 at 17:28 UTC
|
Most certainly your Apache-configuration is not correct. Did you read the Apache manual? The tutorial on "Dynamic Content with CGI" will explain how to make Apache execute your Perl-scripts.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] [Watch: Dir/Any] |
Re: CGI Question
by jrsimmon (Hermit) on Jul 20, 2009 at 17:52 UTC
|
If Apache is set up correctly (assuming it's a current install and you selected the defaults, it is), the problem may be that you are printing something before you print the header. I was recently bit by this bug when I forgot to remove a debug print statement from a script.
You can test whether this is the case by running the cgi script from the command line and ensuring that the first output from the script is/isn't the text/html header. | [reply] [Watch: Dir/Any] [d/l] |
Re: CGI Question
by Anonymous Monk on Jul 20, 2009 at 18:26 UTC
|
On windows, apache will try to execute
shebang , in your example /usr/bin/perl
change it to
#!perl --
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
| [reply] [Watch: Dir/Any] [d/l] [select] |
Re: CGI Question
by targetsmart (Curate) on Jul 21, 2009 at 10:54 UTC
|
This Troubleshooting Perl CGI scripts may help you.
Vivek
-- 'I' am not the body, 'I' am the 'soul', which has no beginning or no end, no attachment or no aversion, nothing to attain or lose.
| [reply] [Watch: Dir/Any] |
|
That is a good guide, but his problem was apache config, and he already solved it.
Thanks
| [reply] [Watch: Dir/Any] |
Re: CGI Question
by linuxer (Curate) on Jul 21, 2009 at 19:08 UTC
|
You should consider to use start_form() and end_form() from CGI to start and finish your HTML form.
You can save many prints if you print a list of $cgi->... elements.
print $cgi->header(),
$cgi->start_html('title'),
$cgi->start_form(),
#... your form here
$cgi->end_form(),
$cgi->end_html(),
;
Update: Maybe you should have a look at a templating system like HTML::Template as well. Using a templating system helps you to separate your HTML content from your perl code. | [reply] [Watch: Dir/Any] [d/l] [select] |