Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

What could prompt an internal server error?

by Anonymous Monk
on Jun 05, 2001 at 08:46 UTC ( [id://85692]=perlquestion: print w/replies, xml ) Need Help??

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

I have a script that, when pulled up from a web browser, does a little processing, and then prints a confirmation of what it did in an html page. Now, The processing on the server goes fine, but when it tries to print the html page, i get a 500 Internal Server Error...and yes, i'm printing the mime-type line ("Content-type: text/html\n\n").

So, i'm wondering, aside from an actual script-not-working-at-all type thing or a bad content-type line, what could cause a 500 error?

keep in mind, it isnt bad file permissions or anything, because the script itself actually runs, just what I print to the browser never gets there. so what could be causing this error?

Edit: chipmunk 2001-06-05

Replies are listed 'Best First'.
Re: What could prompt an i.s.e.?
by dvergin (Monsignor) on Jun 05, 2001 at 08:51 UTC
    Been there. Frustrating.

    One of the following should be helpful:
       a)Running the script from the command line.
       b)Checking the server error log.

    Update:
    Following crazyinsomniac's suggestion here's a slightly different take on some good stuff to include near the top of your script

    use CGI::Carp; use CGI::Carp qw(fatalsToBrowser); local $SIG{__WARN__} = \&Carp::cluck;
      I'm using fatalsToBrowser already.
        But what about suggestions a) and b)?

        Perhaps my "should be helpful" was a little too casual. Those are not throw-away suggestions. They are likely the two most common and effective strategies for solving the kind of problem you describe. If you peruse the archives here at Perl Monks you will see them recommended again and again.

        They will likely lead you to a solution to your current problem. And checking those two things should become second nature for you any time you have a problem of this sort because they are such reliable strategies.

        In particular, find out where your server error log is and befriend it. It is one of your most reliable resources for debugging CGI.

      Try "Content-Type: text/html\n\n";
      Note capital 'T' for 'Type'. Good luck.
        Apache (on both Linux and Windows) is happy to accept each of the following:
        Content-type: text/html Content-Type: text/html CoNtEnT-TyPe: text/html
        The original poster does not mention which server is being used. I can't find a definitive word on capitalization on HTTP headers but the HTTP docs I can lay my hands on seem rather casual about capitalization. YMMV
(crazyinsomniac) Re: What could prompt an i.s.e.?
by crazyinsomniac (Prior) on Jun 05, 2001 at 09:33 UTC
    How do you know that the 'server processing' goes fine?
    Did you develop the script on that server?
    You most likely are trying to use AModule; that isn't installed.
    Are you using CGI::Carp qw(fatalsToBrowser);?
    How about carpout?

     
    ___crazyinsomniac_______________________________________
    Disclaimer: Don't blame. It came from inside the void

    perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Re: What could prompt an i.s.e.?
by bwana147 (Pilgrim) on Jun 05, 2001 at 11:38 UTC

    So, the script actually works, but the output cannot be printed out? Could that be that the script does not run twice? This often happens on modern javascript-laden ebusiness sites, where you can't use the Back button of your browser, lest some cooky is dropped from the jar or the session manager looses its way in the fog.

    I haven't seen the script though, but some browsers reload the page when they print it out. If your script cannot be run twice in a row, you're doomed.

    HTH

    --bwana147

Some other things to check
by mattr (Curate) on Jun 05, 2001 at 10:26 UTC
    It would be helpful if you could post the first 20 lines of your program.

    It is possible that you are not printing the http header early enough. Try adding a line to print that header again for debug purposes right at the top of your program.

    Perhaps you are having trouble including a module or you have a BEGIN block or other initial processing which dies with an error message (when the browser is expecting an http header). Carp is good, but why not first try running it from command line or from browser with that extra header being printed at the beginning. Then you can add print statements as milestones to tell you where your program has gone.

    If this fails also check permissions, try chmod 755 yourscript.cgi also make sure your apache can execute as cgi files with the extension (.pl or .cgi) which you have decided to use. Oh and also make sure you are running perl 5 (type perl -V).

      Another really important possible source of information is your server logs. what do they say? anything? i just debugged something by spending an hour pulling my hair out and smashing my head against a wall and then 30 seconds reading the logfile and fixing the problem it told me about.

      if you're running apache on a unix system, they're likely at /var/log/httpd-error.log or something like it.

Re: What could prompt an i.s.e.?
by converter (Priest) on Jun 05, 2001 at 16:08 UTC

    Try the CGI::Debug module. I've used this module a few times and found it very helpful. If your script causes an error, CGI::Debug appends debugging information to the output so that instead of a very unhelpful "it didn't work" message, you usually end up with enough information to fix the problem. You can even have CGI::Debug send its output to you via e-mail, if you wish.

Re: What could prompt an i.s.e.?
by Anonymous Monk on Jun 05, 2001 at 13:28 UTC
    There is a similar query in comp.lang.perl.misc I think it was settled there by the removal of a blank line in the headers. But check to be sure ;-) Close to my bed time my reliability is very low right now.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://85692]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-06-21 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.