Chris Coggins wrote:
I'm adding this exit step into the script to keep people from trying
to execute it outside of the normal web interface. The script and
browser communicate normally if the script is executed through its
original form. What I'm trying to prevent is someone trying to execute
without using the form, as a sort of hacker deterrent. I could care
less what error messages that person encounters, I just wondered if
the 500 was the normal response via that method of execution.
Jim Gibson wrote:
On 2/8/10 Mon Feb 8, 2010 5:45 PM, "Chris Coggins" <cacogg...@cox.net>
scribbled:
Thanks Jim. I used
exit(0) unless $varA;
and it worked good from command line. When I try the script through a
browser pointing to the file like so
http://domain.com/cgi-bin/script.pl?varA=10
the script executes as it should.
But when I try to send 0 as the value (?varA=0), I get a code 500
internal error. Is this the normal response for a script to prematurely
exit using a browser to run it?
If you are writing a CGI program, you need to make sure your program
returns
the proper HTML to the server before exiting. You shouldn't just exit
the
program prematurely. You need to anticipate all of the errors that might
occur and handle them correctly, generating the proper response to
the user.
Are you using the CGI::Carp module? This module will generate error
pages,
but you should only depend upon these pages during development. Your
users
will not care that your program has encountered an unhandled bug.
See <http://perldoc.perl.org/CGI/Carp.html> for what the module will
do for
you.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/