Hi, Folks
I have a perl scripts like this:
------------------------------------------------------
sub trap_die
{
my @param = @_;
$message = $param[0];
$CommandString = "/bin/mailx -s \"$message\" xxxx\@yyyy.com ";
system ( $CommandString );
}
use strict;
use DBI;
my $dbh = DBI->connect ( 'dbi:Oracle:test',
'system',
'manager',
{
PrintError => 0,
RaiseError => 1,
AutoCommit => 1
}
) || die "Database Connection not made
$DBI::errstr" ;
my $sql = qq{ select * from global_name}
my $sth = $dbh ->prepare($sql);
$sth->execute();
while (my @rows = $sth->fetchrow_array) {
print "@rows[0]\n";
}
$sth->finish();
$dbh->disconnect();
-------------------------------------------------------
For any reason there is an error, perl will exit. Everyday I have to
read output files to see whether there is an error, how can I make a
perl call my sub function TRAP_DIE so that when error, I will get an
email?
I tried to put the line
if ($dbh->error) {trap_die("error");}
but it will not work because the perl will exit as soon as it raise
error.
Thanks for your help.
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp