Reputation: 11
I have a few perl script file which have been up and running for past few years, all of a sudden, for past few days, they were up, down, up, down, ..... There are no syntax error for them, since sometimes they are up, and they have been there for quite a while, i did not change them recently. Plus, I can run them from Lunix shell command without any problem, the file permission is 755, so everything seems to be set up properly. They are hosted by a web hosting company, I have no access to server log file.
The error message is typical perl error message:
"Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log."
Upvotes: 0
Views: 196
Reputation: 1
If your site has recently been transferred onto a different server by your hosting company or the server settings have recently been changed try saving the file with HTML kit by using 'Save as extra' >> 'Save as UNIX format' and then upload.
Upvotes: 0
Reputation: 385655
Add use CGI::Carp qw( fatalsToBrowser );
early in your program to have the error returned to the browser.
Alternatively, you could use the same technique CGI::Carp uses or a wrapper to your script to save the errors in your own log file.
Add the following to the start of a script to have it log errors and warnings to a log file of your choice.
sub self_wrap {
my $log_qfn = "$ENV{HOME}/.web.log"; # Adjust as needed.
open(my $log_fh, '>>', $log_qfn)
or warn("Can't append to log file \"$qfn\": $!"), return;
require IPC::Open3;
require POSIX;
my $prefix = sprintf("[%s] [client %s] ",
POSIX::strptime('', localtime),
$ENV{REMOTE_ADDR} || '???'
);
my $suffix = $ENV{HTTP_REFERER} ? ", $ENV{HTTP_REFERER}" : '';
my $pid = IPC::Open3::open3(
'<&STDIN',
'>&STDOUT',
local *CHILD_STDERR,
$^X, $0, @ARGV
);
while (<CHILD_STDERR>) {
print(STDERR $_);
chomp;
print($log_fh $prefix, $_, $suffix, "\n");
}
waitpid($pid, 0);
POSIX::_exit(($? & 0x7F) ? ($? & 0x7F) | 0x80 : $? >> 8);
}
BEGIN { self_wrap() if !$ENV{WRAPPED}++; }
Upvotes: 4