CGI::Carp fatalsToBrowser does not work all the time as you have discovered. You will be dieing in the open and CGI::Carp does not catch this. Uncomment the typo and it will catch that, but not the die. It is a bug in CGI::Carp which is why I don't bother to use it. See CGI Help Guide for all sorts of tips (including a way to get almost all your errors onto the screen). Anyway this mod will tell you that the path does not exist or you don't have the required perms and you are dieing on the open.....

#!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser); use CGI ':standard'; print "Content-type: text/html\n\n"; my $time = time; my $timepage = "/path/data/back_up/edit/$time.txt"; #typo open FH, "> $timepage" or die_nice( "Can't open $timepage: $!" ); close FH; print "$timepage"; sub die_nice { my ( $err ) = @_; print "Content-Type: text/html\n\n$err\n"; warn "ERR - $err\n"; exit 1; }

I recommend using a die_nice routine in all CGI rather than a naked die. Note I always print a header in this so you won't 500. Also note that I get the header out ASAP so you won't 500. The only really good reason not to put the header out in the first few lines is that you may want to send a cookie or image or other header later.

The other possibilities include no Perl, CGI or CGI::Carp are not installed (so you have compile errors) or no execute perms ie you forgot to chmod 755 your script. But it smells like permissions or path.

PS When this sort of thing occurs the quickest way to the answer is to distill ie try:

#!/usr/bin/perl print "Content-Type: text/html\n\nWe have ignition!" #!/usr/bin/perl use CGI ':standard'; print header(), 'Engage CGI'; #!/usr/bin/perl use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); print header(), 'Enterprise You are clear to go with Carp'; print "Roger Houston testing Carp with typo now etc

cheers

tachyon


In reply to Re: Why does this crash? (Error 500) by tachyon
in thread Why does this crash? (Error 500) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.