#! /usr/bin/perl -w #use warnings; #use strict; use Net::SMTP; use MIME::Lite; ###Deleting the old files unlink ; ###Input from the User print "\n Pls give all your inputs in CAPS\n"; print "Enter the dist id of the package\n"; chop($input=); print "Enter the gateway name of the package\n"; chop($division=); print "Enter the version of the package\n"; chop($version=); ### Declarations my %id=("HTCHSTCGW1"=>"abc\@abc.in", "HTCHTDLGW1"=>"def\@def.in", "HTCHMROGW1"=>"ghi\@ghi.in", "HTCHAM4GW1"=>"jkl\@jkl.in"); my %cc=("HTCHSTCGW1"=>"ppp\@ppp.in", "HTCHTDLGW1"=>"ppp\@ppp.in", "HTCHMROGW1"=>"ppp\@ppp.in", "HTCHAM4GW1"=>"ppp\@ppp.in"); my $mail_host='10.101.26.28'; my $From_address='admin@abc.in'; my $body="Hi, Monthly Patches were distributed to the hosts in $division.\n Results of the $version patches"; ###Distribution Status based on Input if($version eq "2K") { system("wmdist -e $input SUCCESS > 2K_success.txt"); system("wmdist -e $input FAILED > 2K_failed.txt"); system("wmdist -e $input WAITING > 2K_waiting.txt"); } if($version eq "2K3") { system("wmdist -e $input SUCCESS > 2K3_success.txt"); system("wmdist -e $input FAILED > 2K3_failed.txt"); system("wmdist -e $input WAITING > 2K3_waiting.txt"); } if($version eq "XP") { system("wmdist -e $input SUCCESS > XP_success.txt"); system("clear"); system("wmdist -e $input FAILED > XP_failed.txt"); $|=1; system("wmdist -e $input WAITING > XP_waiting.txt"); } my $To_address=$id{$division}; my $cc_address=$cc{$division}; $msg=MIME::Lite->new( From => $From_address, To => $To_address, Cc => $cc_address, Subject =>'Monthly Patches Rollout Distribution Status', Type =>'multipart/mixed' ); $msg->attach( Type =>'Text', Data => "$body" ); if ( $version eq "2K3") { $msg->attach( Type =>'text/html', Path =>'D:/report/2K3_success.txt', Filename =>'2K3_success.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/2K3_failed.txt', Filename =>'2K3_failed.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/2K3_failed.txt', Filename =>'2K3_waiting.txt', Disposition => 'attachment' ); } if ( $version eq "2K") { $msg->attach( Type =>'text/html', Path =>'D:/report/2K_success.txt', Filename =>'2K_success.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/2K_failed.txt', Filename =>'2K_failed.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/2K_failed.txt', Filename =>'2K_waiting.txt', Disposition => 'attachment' ); } if ( $version eq "XP") { $msg->attach( Type =>'text/html', Path =>'D:/report/XP_success.txt', Filename =>'XP_success.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/XP_failed.txt', Filename =>'XP_failed.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/XP_failed.txt', Filename =>'XP_waiting.txt', Disposition => 'attachment' ); } MIME::Lite->send('smtp',$mail_host,Timeout=>60); $msg->send;