0

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."

2
  • 1
    it looks like someone changed server config ( httpd.conf ) , does it work in your test env ? Commented Oct 25, 2013 at 17:26
  • "The error message is typical perl error message" - actually, it's not a Perl error message at all. That error is generated by your web server. Commented Oct 26, 2013 at 9:50

2 Answers 2

4

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}++; }
Sign up to request clarification or add additional context in comments.

1 Comment

Right now, they are ok, next time if they are down again, i will add "CGI::Carp qw( fatalsToBrowser );" to my perl code to see what went wrong, thanks
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.