0
#!/usr/local/bin/perl
#check_oracle#

use strict;

use DBI;
use Net::SMTP;

$ENV{'ORACLE_HOME'} = '/app/oracle/product/9.2';

my $errors;
my $total = 0;

check_oracle();

if($total > 0) {
   my $mailer = Net::SMTP->new("142.1.0.1");
   $mailer->mail('dpr-prod@repl1.newport.net');
   $mailer->to('root');

   $mailer->data();
   $mailer->datasend("Subject: DPR database");
   $mailer->datasend("\n");
   $mailer->datasend($errors);
   $mailer->dataend();
} 

sub check_oracle {
   my $username = '######_@@@@';
   my $password = '@@@@';
   my $tnsalias = 'DPR';

   my $dbh = DBI->connect('dbi:Oracle:'.$tnsalias, $username, $password, { PrintError => 0 });
   unless($dbh) {
         $errors .= "DPR database may be unavailable.\n";
         $total++;
      };
}

Edited by Reverend Jim: Fixed formatting

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by KevinADC
0

anyways, why should anyone just correct your code for you even if there is a problem? This is not a code debugging/ script writing service, it's a help forum.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.