Use CGI::CARP qw(fatalsToBrowser) not working

Hi all,
When I include this line in the script, the errors don't appear within
the browser window. I am still having to dig through the error_log to
find out what happened, or execute perl test.cgi from a terminal window.

The following is displayed in the browser if any error occurs within the
script:

SERVER ERROR
The server encountered an error ………….
Error message:
Premature end of script headers: test.cgi

OS: recently installed RH9 (SHRIKE)

Could this be an Apache httpd.conf setup error?
Joe Blow [ Fr, 03 Dezember 2004 13:13 ] [ ID #517949 ]

Re: Use CGI::CARP qw(fatalsToBrowser) not working

[ Subject: Use CGI::CARP qw(fatalsToBrowser) not working ]

Joe Blow wrote:
> When I include this line in the script, the errors don't appear within
> the browser window.

Perl is case sensitive.

use CGI::Carp qw(fatalsToBrowser);

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson [ Fr, 03 Dezember 2004 14:05 ] [ ID #517950 ]

Re: Use CGI::CARP qw(fatalsToBrowser) not working

Hi again all,
I posted the question as: Use CGI::CARP qw(fatalsToBrowser) not working
When in fact the code I have within the script is:
use CGI::Carp qw(fatalsToBrowser)

This is not functioning correctly. The outputs don't go to the browser
window.

Anybody with any hints?

Joe

Thanks - Gunnar Hjalmarsson for pointing out the mistake in the subject
line

Joe Blow wrote:
>
> Hi all,
> When I include this line in the script, the errors don't appear within
> the browser window. I am still having to dig through the error_log to
> find out what happened, or execute perl test.cgi from a terminal window.
>
> The following is displayed in the browser if any error occurs within the
> script:
>
> SERVER ERROR
> The server encountered an error ………….
> Error message:
> Premature end of script headers: test.cgi
>
> OS: recently installed RH9 (SHRIKE)
>
> Could this be an Apache httpd.conf setup error?
Joe Blow [ Sa, 04 Dezember 2004 00:25 ] [ ID #518857 ]

Re: Use CGI::CARP qw(fatalsToBrowser) not working

[ Please do not top-post! ]

Joe Blow wrote:
>
> use CGI::Carp qw(fatalsToBrowser)
>
> This is not functioning correctly. The outputs don't go to the
> browser window.
>
> Anybody with any hints?

Is CGI::Carp correctly installed? Try this script:

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/plain\n\n";
print CGI::Carp->VERSION, "\n";

Are you running under mod_perl?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson [ Sa, 04 Dezember 2004 01:22 ] [ ID #518858 ]

Re: Use CGI::CARP qw(fatalsToBrowser) not working

"Joe Blow" <joe [at] joe.com.ph> wrote in message
news:41B0F551.1F3B9FE0 [at] joe.com.ph...
>>
>> The following is displayed in the browser if any error occurs within the
>> script:
>>
>> SERVER ERROR
>> The server encountered an error .....
>> Error message:
>> Premature end of script headers: test.cgi
>>

Well, the obvious question is are you sending the correct headers? Sounds
like your script is executing fine, but your sending an improper header to
the browser, and malformed http headers are not going to be caught by the
perl interpreter.

Matt
Matt Garrish [ Sa, 04 Dezember 2004 04:56 ] [ ID #518859 ]

Re: Use CGI::CARP qw(fatalsToBrowser) not working

Matt Garrish wrote:
> "Joe Blow" <joe [at] joe.com.ph> wrote in message
> news:41B0F551.1F3B9FE0 [at] joe.com.ph...
>
>>>The following is displayed in the browser if any error occurs within the
>>>script:
>>>
>>>SERVER ERROR
>>>The server encountered an error .....
>>>Error message:
>>>Premature end of script headers: test.cgi
>
> Well, the obvious question is are you sending the correct headers?

Not that obvious, since CGI::Carp prints a content-type header. The OP
also gave the impression that the script normally runs without errors
("if any error occurs").

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson [ Sa, 04 Dezember 2004 12:00 ] [ ID #519345 ]

Re: Use CGI::CARP qw(fatalsToBrowser) not working

"Gunnar Hjalmarsson" <noreply [at] gunnar.cc> wrote in message
news:31djm2F3a246vU1 [at] individual.net...
> Matt Garrish wrote:
>> "Joe Blow" <joe [at] joe.com.ph> wrote in message
>> news:41B0F551.1F3B9FE0 [at] joe.com.ph...
>>
>>>>The following is displayed in the browser if any error occurs within the
>>>>script:
>>>>
>>>>SERVER ERROR
>>>>The server encountered an error .....
>>>>Error message:
>>>>Premature end of script headers: test.cgi
>>
>> Well, the obvious question is are you sending the correct headers?
>
> Not that obvious, since CGI::Carp prints a content-type header. The OP
> also gave the impression that the script normally runs without errors ("if
> any error occurs").
>

Ahh, I didn't read down through the tofu. All I saw was his reply that it's
not working and that he's getting a header error. I'm still suspect as to
what these errors are that he believes should be caught by CGI::Carp.

Matt
Matt Garrish [ Sa, 04 Dezember 2004 18:12 ] [ ID #519619 ]

Re: Use CGI::CARP qw(fatalsToBrowser) not working

Gunnar Hjalmarsson wrote:
>
> [ Please do not top-post! ]
>
> Joe Blow wrote:
> >
> > use CGI::Carp qw(fatalsToBrowser)
> >
> > This is not functioning correctly. The outputs don't go to the
> > browser window.
> >
> > Anybody with any hints?
>
> Is CGI::Carp correctly installed? Try this script:
>
> #!/usr/bin/perl
> use CGI::Carp qw(fatalsToBrowser);
> print "Content-type: text/plain\n\n";
> print CGI::Carp->VERSION, "\n";
>
> Are you running under mod_perl?
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

The output of the above script was 1.24
Joe Blow [ So, 05 Dezember 2004 04:18 ] [ ID #519906 ]

Re: Use CGI::CARP qw(fatalsToBrowser) not working

Joe Blow wrote:
> Gunnar Hjalmarsson wrote:
>>
>> #!/usr/bin/perl
>> use CGI::Carp qw(fatalsToBrowser);
>> print "Content-type: text/plain\n\n";
>> print CGI::Carp->VERSION, "\n";
>>
>>Are you running under mod_perl?
>
> The output of the above script was 1.24

Can you show us a small script with an error that is not captured by
CGI::Carp as you would have expected?

IIRC, version 1.24 is buggy. It may be worth to try the latest version.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson [ So, 05 Dezember 2004 09:52 ] [ ID #520114 ]
Perl » alt.perl » Use CGI::CARP qw(fatalsToBrowser) not working

Vorheriges Thema: CGI and param() problem
Nächstes Thema: Image mapping script