yanfangsheng123 发表于 2017-5-18 07:30:36

perl实现异常时报警

  #!/usr/bin/perl -w
use DBI;
use LWP::Simple qw(get);
  # $driver="mysql";
$dbh=DBI->connect("DBI:mysql:csunet:localhost","root","")||die"can not connect database";
  # 产生当天日期
$year = (gmtime time) + 1900;
$month = (gmtime time) + 1;
$date = (gmtime time);
$today = $year."-".$month."-".$date;
  $sql = "select phone from duty_info where RiQi='" .$today. "'";
  $sth=$dbh->prepare($sql) || die "Occur an error when query database!";
$sth->execute();
$numRows=$sth->rows;
  while(@row=$sth->fetchrow_array)
{
$number = $row;
}
  if($numRows == 1)
{
my $url = 'http://202.197.54.130:9999/cgi-bin/csend.exe?N=13687363993,' .$number. '&M=省网7206路由器出现故障请检查';
my $content = get $url;
  print $content;
print "/n";
}
  print "满足条件的数为: $numRows /n";
print $today;
print "/n";
print $sql;
print "/n";
  $sth->finish();
$dbh->disconnect();
  exit 0;
页: [1]
查看完整版本: perl实现异常时报警