[ORACLE@YYJK esb]$ cat a1.pl use DBI;
Use HTTP::D ate qw (time2iso str2time time2iso time2isoz);
Use NET::SMTP;
Use Encode;
My $dbName = ' esbdb ';
My $dbUser = ' esbdata ';
My $dbUserPass = ' esbdata ';
My $dbh = Dbi->connect ("Dbi:oracle: $dbName", $dbUser, $dbUserPass) or die "can ' t connect to database"; My $sql = "Select Logicsystem,count (*) from Esb2_trans_log t where T.trans_date >= sysdate-30/1440 and T.respcode
= ' 500101092209 ' and t.logicsystem<> ' Tlchat ' GROUP by Logicsystem have Count (*) >0 ";
Sub sendsms{use lwp::useragent;
Use LWP;
Use Encode;
Use Lwp::simple;
Use lwp::useragent;
Use http::cookies;
Use Http::headers;
Use Http::response;
Use Encode;
Use Uri::escape;
Use Uri::url;
Use JSON;
My $ua = lwp::useragent->new; $ua->agent ("mozilla/5.0" (Windows NT 6.1;
rv:30.0) gecko/20100101 firefox/30.0 "); My $cookie _jar = http::cookies->new (file=> ' Lwp_cookies.txT ', autosave=>1, ignore_discard=>1);
$ua->cookie_jar ($cookie _jar);
My $token _url= ' http://10.10.10.10:8080/tlcbspt/sendText ';
My $a =shift;
My $b =shift; My $res = $ua->post ($token _url, {' Phoneno ' => $a, ' message ' =>
; $b});
Print $res->content ();
print "\ n";
};
Sub sendelk{use io::socket::inet; $|=1;
$sock = io::socket::inet->new (peeraddr => ' 10.10.10.10 ', Peerport => ' 9988 ',
Proto=> ' TCP ') or Die "$!\n";
My $req =shift;
My $size = $sock->send ($req);
Print "sent data of length $size \ n";
# # Notify server that request has been sent shutdown ($sock, 1);
# # Receive a response of 1024 characters from server my $response = ';
$sock->recv ($response, 1024);
Print "received response: $response \ n"; $sock,; Close ();
};
My $sth = $dbh->prepare ($sql);
$sth->execute ();
$sth->bind_columns (undef, \ $system, \ $count);
$sth->execute ();
while ($sth->fetch ()) {print "$system \t\t $count \ n";
Chomp $count;
if ($count >=0) {My $message = "alarm [$system] The number of timeout pens in 3 minutes is [$count], please watch!!!";
my $c = $message; Print $c. "
\ n "; Print Length ($c). "
\ n ";
My $d =decode_utf8 ($message); Print Length ($d). "
\ n "; Print $d. "
\ n ";
&sendsms (' 18072xx2237 ', "$d");
#my $e =decode_utf8 ($c);
&sendelk ("$c");
}};
$sth->finish;
My $d =decode_utf8 ($message);
Decode_utf8 is decoded to the Unicode character set $message itself is the utf-8 character set [Oracle@yyjk esb]$ perl a1.pl SSRS 2 Alarms [ssrs]3 minutes with a timeout number of [2], please watch!!!
Wide character in print at a1.pl Line 73.
Alarm [ssrs]3 minutes Timeout pen number is [2], please note that observe the!!!
Sent data of length received Response:cips 2 alarm [cips]3 minute timeout number is [2], please note the observation!!! Wide character in print at a1.pl Line 73.
Alarm [cips]3 minutes Timeout pen number is [2], please note that observe the!!!
Sent data of length received response: