Re: Perl/Apache Error
by AgentM (Curate) on Feb 27, 2001 at 03:07 UTC
|
Since you don't actually include the relevant part with the printing of the headers, it would be rather difficult to help you. Instead of 'parsform.cgi', try CGI.pm. It is easy to use and won't open blatant security holes involved with those copy-n-paste solutions. If it still doesn't work after replacing your stuff with CGI stuff, then come back and complain....
try this:
use CGI:
my $q=new CGI;
print $q->header;
print '<html><body>Test</body></html>';
AgentM Systems nor Nasca Enterprises nor
Bone::Easy nor Macperl is responsible for the
comments made by
AgentM. Remember, you can build any logical system with NOR.
| [reply] [d/l] |
(Ovid) Re: Perl/Apache Error
by Ovid (Cardinal) on Feb 27, 2001 at 03:08 UTC
|
I can't tell just from your code what's going on, but you don't wamt to comment out "use strict".
Have you run the script from the command line to see what's happening? Is is printing out valid headers? My guess is that you tried to use an undeclared variable and your script died, thus not sending out proper headers.
I see that you have require 'parsform.cgi'; at the top of your code. You should really read this node for information why a hand-rolled CGI parsing routine is bad. Heck, post the form parsing routine and I'll point out all of the errors in it (and I'll bet a fair chunk of my salary that I can find errors in it).
Again, run the code from the command line and see what it puts out. Don't run scripts without strict and make sure that you enable warnings and taint checking (warnings can be disabled in production as they are not as important and have a performance penalty).
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. | [reply] |
|
|
Thanks for all your replys. This code is for a college computing asignment and we are supposed to use as little of other peoples code as possible. I know that there are huge advantages to using CGI.pm and for other stuff I would use it but if I can avoid it, it would be great as I can get more coding marks (besides, the server this is on only runs on my LAN behind a firewall so security is not a huge concern :) The parse_form that is required is the one by Craig Patchett & Matthew Wright from the CGI/Perl Cookbook.
| [reply] |
|
|
| [reply] |
|
|
Not putting use CGI.pm; is like not putting #include <stdio.h>
It's just not done that way.
In other words, you're not really using other people's code,
you're allowing yourself access to a well-accepted (some might
even say universally accepted) API that helps you get your
job done quicker. In other words, half the essence of programming.
ALL HAIL BRAK!!!
| [reply] [d/l] [select] |
|
|
If your intent is to use as littleof other people's code as possible, at least make sure that it's good code. CGI.pm is good code. Matt Wright has a poor reputation in the security department (and in the Y2K department (and...)))
| [reply] |
Re: Perl/Apache Error
by archon (Monk) on Feb 27, 2001 at 03:07 UTC
|
You need to check your web error log for the rest of the error messages. I am guessing that you violated a strict policy since commenting out that line makes your script work. The problem could also be in one of the scripts that you are requireing.
You should check out the requirements that use strict entails. You might also want to check out the -T (taint) option for Perl since you are doing CGI.
Basically, you didn't provide us enough information to diagnose your problem. Either check your error log or run the script from the command line for the details. | [reply] [d/l] [select] |
Re: Perl/Apache Error
by mr.nick (Chaplain) on Feb 27, 2001 at 03:55 UTC
|
In the future, Alex, you might want to think about putting a
use CGI::Carp qw(fatalsToBrowser);
in your code. This will cause all error messages to be prefixed with the text necessary for them to display on Web browsers. Even if you don't use any of CGI's functions, this is solely for ease of debugging.
If you have access to the error logs of web server, look at them; they will contain the error that Perl spewed out:
(Mon Feb 26 17:52:05 2001) (error) (client 10.0.1.2) (Mon Feb 26 17:52:05 2001) bad.cgi: Global symbol "$x" requires explicit package name at bad.cgi line 6.
(Mon Feb 26 17:52:05 2001) (error) (client 10.0.1.2) (Mon Feb 26 17:52:05 2001) bad.cgi: Execution of bad.cgi aborted due to compilation errors.
</small
| [reply] [d/l] |
Re: Perl/Apache Error
by sierrathedog04 (Hermit) on Feb 27, 2001 at 05:51 UTC
|
If you run your CGI script from the command line, as in perl -w my_cgi_script.pl, do you still get an error? The advantage of running the script from the command line is that you often get a more descriptive error message, including line number where the error occurred.
I would say that ninety-nine percent of the time I get the premature-end-of-header CGI error the problem has nothing to do with CGI and the script won't run from the command line either.
| [reply] |
|
|
I have bowed to the superior knowledge of my fellow monks and used CGI.pm
FYI, I got no error on the command line, only when run through the webserver. (and what I posted was the error log :) )
Thanks for your help
Alex
| [reply] |