PERL SCRIPT TO SENT MAIL USING ISP URL WHILE ANY INCIDENT IS RAISED/ UPDATED AS CRITICAL IN REMEDY

helmetpastoralΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

69 εμφανίσεις

PERL SCRIPT TO SENT MAIL USING ISP

URL WHILE ANY INCIDENT IS
RAISED/

UPDATED AS
CRITICAL IN REMEDY


#!/usr/bin/perl

use warnings;


# Store the incident number in output_perl.txt and store this as variable text1

#
--------------

open my $fh, '<','output_per
l.txt'


or die "Failed: $!
\
n";


my $text1 = do {


local $/;


<$fh>

};


close $fh


or die "Failed again: $!
\
n";

#
--------------



#Store the Incident Desription in output_perl_1.txt and store this as variable text2

#
--------------

open my $i, '<
','output_perl_1.txt'


or die "Failed: $!
\
n";


my $text2 = do {


local $/;


<$i>

};


close $i


or die "Failed again: $!
\
n";

#
--------------


#Store the Current Timestamp in output_perl_2 and store this as variable text3

#
--------------

open my
$j, '<','output_perl_2'


or die "Failed: $!
\
n";


my $text3 = do {


local $/;


<$j>

};


close $j


or die "Failed again: $!
\
n";

#
--------------



#Store the Incident Categorization 1 in output_perl_3 and store this as variable text4

#
------------
--

open my $k, '<','output_perl_3'


or die "Failed: $!
\
n";


my $text4 = do {


local $/;


<$k>

};


close $k


or die "Failed again: $!
\
n";

#
--------------




# CREATION OF MESSAGE BODY JOINING EACH OF THE PARAMETER TAKEN FROM INCIDENT

#
-----------
---

my $message = join "","$text1","
-
","Critical Incident Alert","
-
","$text2","
-
","$text4","
-
","$text3","
-
","Support
Teams has already been informed about this. They will verify and investigate it. An Incident Management Email
will follow this text informi
ng more details of this issue.
\
n";

#
--------------



# SENDING SMS USING ISP

URL

#
--------------

use LWP 5.64;

my $browser = LWP::UserAgent
-
>new;

my $url =join "","http://
XXXXXXXXXX
/http/s
endPlainText?msisdn=SSSSS
&message=","$message
","&username=UUUU&pass
word=PPPPPP
&originator=SRV_REMEDY";


#print $url;

my $response = $browser
-
>get($url);

#
--------------





N.B:

1. ISP Url has been replaced by XXXXXXXXXX.

2. Phones number has beeen replaced by SSSSS.

3. User name has been replaced by UUUU.

4. Password ha
s beeen replaced by PPPPPP.