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

i get script error 500 when i view the cgi file online... whats wrong wid it? heres the code:
#!/usr/bin/perl print "content-type:text/html\n\n"; use CGI; use CGI::Carp qw(fatalsToBrowser); use warnings; %FORM= CGI::Vars; print<<html1; <html> <head> <title>Register online</title> </head> <body style="background-color:#BC9FAC;"> <br><br> html1 open(frame,'/home/www/xxxxxxxxxxxxxxxxxxxx.org/frame.txt') or die "err +or is: $!"; while(<frame>) { print "$_\n"; } close(frame); print<<html2; <br><br> <center> <div style="margin:0 auto;width:750px;height:420px;"> html2 open(frame_left,'/home/www/xxxxxxxxxxxxxxxxxxxxxxxx.org/local_frame_le +ft.txt') or die "error is $!"; while(<frame_left>) { print "$_\n"; } close(frame_left); print<<html3; <div style="width:534px; height:400px;float:right"> <form method="post" action=""> html3 print<<htmlx; Give me details for my Area : <select name="area"> <option value='abc'>abc <option value='def'>def </select> <input type="hidden" name="step" value="2"> <input type="submit" value="Go"> </form> </div> </div> </center> htmlx open(frame_bottom,'/home/www/xxxxxxxxxxxxxxxxxx.org/frame_bottom.txt') +; while(<frame_bottom>) { print"$_\n"; } close(frame_bottom); print<<htmlx2; </body> htmlx2

Replies are listed 'Best First'.
Re: why am i getting script error 500
by waldner (Beadle) on Jun 21, 2008 at 15:32 UTC
    I don't know why you get that error, however you will likely find a clear description of the problem in the log of your webserver.
Re: why am i getting script error 500
by pc88mxer (Vicar) on Jun 21, 2008 at 15:42 UTC
    I'll re-iterate what waldner suggests - you should find clues as to what's going on in the error log of your web server.

    Some more pointers...

    • Add use strict.
    • I think CGI::Vars is deprecated. Use param() instead.
    • Instead of emitting the header yourself, have CGI do it for you with print header;
Re: why am i getting script error 500
by psini (Deacon) on Jun 21, 2008 at 15:35 UTC

    Error 500 is a generic server error message. It says only that the server (apache?) could not fulfill your request.

    Not knowing which web server software are you using I can't be more specific; if it is apache, you should have an error log file generated by apache logging and explaining all server errors occurred (on my debian linux it is named /var/log/apache2/error.log, but name and path may vary depending on your OS and distro)

    Careful with that hash Eugene.

Re: why am i getting script error 500
by CountZero (Bishop) on Jun 21, 2008 at 20:44 UTC
    There could be a lot of things wrong with your script.

    However as the server responds with a "500 server error" and you do not see the error message itself, notwitstanding the use CGI::Carp qw(fatalsToBrowser);, it looks as if CGI:/Carp is not installed on this server. This is very strange since CGI:/Carp is a core-module since Perl 5.04. So either the server has a broken Perl distribution; or has a pre-5.04 Perl running; or the cause is something entirely different. Probably the latter ...

    Do other of your Perl-scripts run on the server without a problem? Did you try a very simple "Hello World" type of program to see if that works? If not, perhaps you are simply not allowed to run CGI-scripts at all?

    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

      sorry for not being clear. actually the page local.cgi shows up the page initially. cgi is working since a hello world program runs fine when viewed on the web. The script 500 error shows up when i hit the go button( submit button in a form on the local.cgi page) the form goes to the local.cgi page itself on submition, since i have specified form action as "". why is this error coming?
        What happens when you fill in the action attribute with an absolute URI rather than leaving it blank?

        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