On Friday, Jun 13, 2003, at 07:45 US/Pacific, Nicholas Davey wrote: [..]
failed to open log file
fopen: Permission denied
[Fri Jun 13 07:45:57 2003] [error] [client 64.207.81.146] Premature end of script headers: <path removed for security reasons>/cgi-bin/index.cgi


Don't worry about the path. All that matters is what could be wrong. If my syntax in 100% correct, and I return the proper Content-type headers, what's the deal? Any comments would be great.


The problem is that the 'fopen()' is bubbling up
in what is in essence a 'die' type, hence never getting
to the case where one can execute the rest of the code.

Allow me to illustrate with probably the dumbest piece of
code that should NEVER BE USED!

[jeeves: 6:] perl -e 'open(FD, ">/etc/passwd") or die "unable to open: $!\n"; '
unable to open: Permission denied
[jeeves: 7:]


What you will find me doing is handing those types of problems
in a way that allows me to 'bubble up the exception' and deal
with it in some boring way like:

        sub log_this
        {
                my ($msg, $log_file) = @_;

$log_file ||= '/some/path/here/the.log';

                open(LOG, ">> $log_file ") or
                        return(1, "logfile open failed: $!");

print LOG $msg;

close(LOG) or return (1, "logfile close failed: $!");

                (0,'HappyHappyJoyJoy');
        }

hence I would call it with

my ($status, $message) = log_this($logable_msg, $der_log_file);

        if ( $staus )
        {
                Generate_Error_page($status, $message);
        } else {
                #
                # deal with the process of doing the page
                #
        }

So my recommendation is to find out where you are trying to
open a logfile, and how to protect that open, so that in
the case where it fails, you can 'catch' the exception,
and try something else...

alternatively cf:

perldoc CGI::Carp

and just use their wrappers to deal with the

         use CGI::Carp qw(fatalsToBrowser);
         die "Bad error here";

Ok?

ciao
drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to