关闭

perl实现异常时报警

标签: perldatabasesqlmysqldate路由器
1950人阅读 评论(0) 收藏 举报
分类:

#!/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)[5] + 1900;
$month = (gmtime time)[4] + 1;
$date = (gmtime time)[3];
$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[0];
}

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;

 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2755301次
    • 积分:25544
    • 等级:
    • 排名:第238名
    • 原创:201篇
    • 转载:537篇
    • 译文:0篇
    • 评论:367条
    最新评论