On Mon, May 31, 2010 at 6:22 AM, Ravi Jaya <[email protected]> wrote:
> I got into some issues, when I tried to use Perl DBI module. lets say when
> you try to connect to the MySQL instance [server], if the server is already
> down, then connection statement throws you the error and stops the script
> execution.

Script stops execution because you have not handled the case where
connect() fails.

Use:
my $dbh = DBI->connect(...) or mysendmail("Cannot connect to DB: " .
DBI->errstr);

It's good programming practice to always check the return values of your
system and function calls.


If you are running this script through cron/at then be truly lazy (it's one of
the virtues of a perl programmer right?) and don't bother with sendmail at all.
Any output on stderr will be automatically emailed by cron/at to the configured
email address.  Just use the regular warn/die calls in Perl and cron/at will
automatically take care of emailing them to your user.

- Raja
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to