CGI-Out

 view release on metacpan or  search on metacpan

lib/CGI/BigDeath.pm  view on Meta::CPAN


# Copyright (C) 1996, David Muir Sharnoff

#
# This is not a package.  
#
# use require to get at it if you have to.
#

use vars qw($mailserver);

sub bigdeath
{
	my ($perlerr, $syserr, $bomb, $out, 
		$envr, $query, $pwd, $zero, 
		$argvr, $debug, $mailto) = @_;

	local $SIG{__DIE__} = undef;
	my $cout = $out;
	$cout =~ s/\</&lt;/g;
	$cout =~ s/\>/&gt;/g;

	$mailto = getpwuid($<)
		unless $mailto;

	print <<"";
Content-type: text/html
\n
		<html>
		<head>
		<title>Error!</title>
		</head>
		<body>
		The dynamic web page that you just tried to
		access has failed.  The exact error that it 
		failed with was:
		<xmp>
		$bomb
		</xmp>
		In addition the following may be of interest:
		<xmp>
		\$\@ = $perlerr
		\$! = $syserr
		</xmp>
		There is probably no need to report this error because 
		email has been sent to $mailto with the information below.
		<p>
		Had this CGI run completion, the following 
		would have been output (collected so far):
		<ul>
		<pre><tt>
$cout
		</tt></pre>
		</ul>


	require Net::SMTP;
	my $smtp = Net::SMTP->new($mailserver || 'localhost');

	$smtp->mail($mailto);
	$smtp->to($mailto);
	$smtp->data();

	my $remoteuser = $ENV{'REMOTE_USER'} || 'unknown';
	my $remotehost = $ENV{'REMOTE_ADDR'} || 'unknown';

	$0 =~ m'([^/]+)$';
	my $sn = $1 || $0;

	$smtp->datasend(<<"");
To: $mailto
From: $remoteuser\@$remotehost
Subject: Perl script $sn bombed
\n
Perl script $0 bombed.
\n
Bomb code:
$bomb
\n
\$\@ = $perlerr
\$! = $syserr
\n
Debugging info:



( run in 1.579 second using v1.01-cache-2.11-cpan-39bf76dae61 )