Send it to an error sub ?
connect("dbi:Pg:dbname=$dbname;host=$host;port=$port;","$username",
"$password", {AutoCommit => 1})
or &Error("error message");
sub Error {
my ($errormessage) = @_
sendmail
etc
}
HTH
Stu
-----Original Message-----
From: Ravi Malghan [mailto:[EMAIL PROTECTED]
Sent: 02 July 2008 13:44
To: [email protected]
Subject: Perl how to die without printing out a message?
Hi: I connect to a database within my script. If the script cannot connect, I
want it to send an email and terminate without printing any message on stdout.
I have the following code
$dbh =
DBI->connect("dbi:Pg:dbname=$dbname;host=$host;port=$port;","$username",
"$password", {AutoCommit => 1})
or die notifyError($message, $subject);
When I run the script, it does call the notifyError function fine and I receive
the email. But it spits out the following message. Any way I can terminate
without putting any message on the screen?
-bash-3.00$ processRemedySubmit.pl
DBI connect('dbname=data;host=hostA;port=5435;','postgres',...) failed: could
not translate host name "hostA" to address: node name or service name not known
at ./scripts/processRemedySubmit.pl line 32
Died at ./scripts/processRemedySubmit.pl line 32.
Thanks
Ravi
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
Information in this email including any attachments may be privileged,
confidential and is intended exclusively for the addressee. The views expressed
may not be official policy, but the personal views of the originator. If you
have received it in error, please notify the sender by return e-mail and delete
it from your system. You should not reproduce, distribute, store, retransmit,
use or disclose its contents to anyone. Please note we reserve the right to
monitor all e-mail communication through our internal and external networks.
SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and
are used under licence. British Sky Broadcasting Limited (Registration No.
2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home
Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited
(Registration No. 2340150) are direct or indirect subsidiaries of British Sky
Broadcasting Group plc (Registration No. 2247735). All of the companies
mentioned in this paragraph are incorporated in England and Wales and share the
same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/