Files List
===============================
MobilkomLieMain.pl
CustomerGenericProcedure.pl
send_scp.sh
send_scp_mach.shsend_file_list.sh
send_scp_late.sh
send_scp.bat
send_scp_mach.bat
sendMail.bat
MobLieMailBody.txt
===============================
MobilkomLieMain.pl
#! /usr/bin/perl
use DBI;
use Net::FTP;
use Time::gmtime;
use File::Copy;
use strict;
use warnings;
#===================================================
#sub routines Start
#===================================================
sub getDate
{
use Time::gmtime;
my $tm=gmtime; my $day; my $month; my $year;
($day,$month,$year) = (gmtime) [3,4,5];
my $locDate=sprintf("%04d%02d%02d",$tm->year+1900,($tm->mon)+1,$tm->mday);
return $locDate;
}
sub getTime
{
use Time::gmtime;
my $lt=gmtime; my $hour; my $minute; my $seconds;
($hour,$minute,$seconds)=(gmtime) [1,2];
my $LocTime = sprintf ("%02d%02d%02d",$lt->hour,$lt->min,$lt->sec);
return $LocTime
}
#===================================================
#sub routines End
#===================================================
#==========================================
# main()
#==========================================
my $runDate=getDate();
my $runTime=getTime();
#---------------------------------
#run_mode=Must be either TEST/PROD
my $RUN_MODE_PROD="PROD";
my $RUN_MODE_TEST="TEST";
my $run_mode=$RUN_MODE_PROD;
my $GET_FILES_N='N';
my $GET_FILES_Y='Y';
my $getFilesInd=$GET_FILES_Y;
#---------------------------------
# For re-run of status 7 and 9:
#---------------------------------
# 1. set $getFilesInd=$GET_FILES_N;
# 2. verify CD*.success file(s) exist in folder $customerRootFolder\taptext_tap310_converter\processed\
# $getFilesInd=$GET_FILES_N;
#---------------------------------
#=======================================
#Variables
#=======================================
my $customerRootFolder="";
my $customerRootFolderWin="";
my $customerRootFolderLin="";
my $os_tap_files_path="";
my $zippedDir="";
my $unzippedDir="";
my $logFile="";
my $convInDir="";
my $convDir="";
my $convProcDir="";
my $unzip_cmd="";
my $filesFolder="";
my $myGate="";
my $SentFileListFileName="";
my $RepFilePath="";
my $sendMailBatFile;
my $sendScpBatFile;
my $FilesToProcess="FilesToProcess.txt";
my $zippedFile="ZippedTextFiles.zip";
my $RetCode='';
my $myDateOverride='';
my $myLastDayOverride='';
my $myScript='';
my $sendMailbat='';
my $debugInd='';
#=======================================
#Customer settings
#=======================================
if ($run_mode eq $RUN_MODE_PROD){
$customerRootFolder="D:/MobilkomLieTaps";
$customerRootFolderWin="D:\\MobilkomLieTaps";
$customerRootFolderLin="/cygdrive/d/MobilkomLieTaps";
$os_tap_files_path="/software/oracle/admin/igt/utl_file/LIE_TAPS";
$sendMailbat="sendMail.bat";
}else{
$customerRootFolder="D:/MobilkomLieTaps";
$customerRootFolderWin="D:\\MobilkomLieTaps";
$customerRootFolderLin="/cygdrive/d/MobilkomLieTaps";
$os_tap_files_path="/starhome/iu/TAP_FILES/TEST/Source/MobilkomLieTaps";
$sendMailbat="sendMailTest.bat";
}
$SentFileListFileName="SentFileLisLIEMX";
$filesFolder="054Files";
$myGate="054";
$myScript="MobilkomLieMain.pl";
$RepFilePath=$customerRootFolderWin."\\repdir\\";
$zippedDir=$customerRootFolderWin."\\".$filesFolder."\\Zipped\\";
$unzippedDir=$customerRootFolderWin."\\".$filesFolder."\\";
$logFile=$customerRootFolderWin."\\Logs\\runLog_".$runDate."_".$runTime.".txt";
$convDir=$customerRootFolderWin."\\"."taptext_tap310_converter";
$convInDir=$convDir."\\input";
$convProcDir=$convDir."\\processed";
$unzip_cmd="7z e -y ".$customerRootFolder."/".$filesFolder."/Zipped/".$zippedFile." -o".$customerRootFolderWin."\\".$filesFolder;
$sendMailBatFile=$customerRootFolderWin."\\".$sendMailbat;
$sendScpBatFile=$customerRootFolderWin."\\send_scp.bat";
$debugInd="N";
#=======================================
#Override Dates
#=======================================
#$myDateOverride='20140326';
#$myLastDayOverride='';
#=======================================
#Database settings
#=======================================
my $db_username='';
my $db_pass='';
my $db_user_string='';
my $user_string='';
my $host_ip='';
my $os_user='';
my $os_pass='';
if ($run_mode eq 'PROD'){
$db_username="collector_user_prod";
$db_pass="collector_pass_prod";
$user_string='dbi:Oracle:collector_conn_str';
$host_ip="111.222.333.444";
$os_user='oracle';
$os_pass='oracle_pass';
}else{
$db_username="collector_user_test";
$db_pass="collector_pass_test";
$user_string='dbi:Oracle:collector_conn_str';
$host_ip="111.223.333.555";
$os_user='os_user';
$os_pass='os_pass';
}
my $result=system($^X,"CustomerGenericProcedure.pl",
#00
$run_mode,
$db_username,
$db_pass,
$user_string,
$host_ip,
#05
$os_user,
$os_pass,
$filesFolder,
$myGate,
$customerRootFolder,
#10
$customerRootFolderWin,
$customerRootFolderLin,
$os_tap_files_path,
$zippedDir,
$unzippedDir,
#15
$logFile,
$convDir,
$convInDir,
$convProcDir,
$SentFileListFileName,
#20
$unzip_cmd,
$RepFilePath,
$sendMailBatFile,
$FilesToProcess,
$myDateOverride,
#25
$myLastDayOverride,
$getFilesInd,
$debugInd
);
print $myScript." Finished with Status: ".$result."\n";
CustomerGenericProcedure.pl
#! /usr/bin/perl
use DBI;
use Net::FTP;
use Time::gmtime;
use File::Copy;
use strict;
use warnings;
#================================
# Input Parameters Start
#================================
my $run_mode = shift;
my $db_username = shift;
my $db_pass= shift;
my $user_string = shift;
my $host_ip = shift;
#05
my $os_user = shift;
my $os_pass = shift;
my $filesFolder = shift;
my $myGate = shift;
my $customerRootFolder = shift;
#10
my $customerRootFolderWin = shift;
my $customerRootFolderLin = shift;
my $os_tap_files_path = shift;
my $zippedDir = shift;
my $unzippedDir = shift;
#15
my $logFile = shift;
my $convDir = shift;
my $convInDir = shift;
my $convProcDir = shift;
my $SentFileListFileName = shift;
#20
my $unzip_cmd = shift;
my $RepFilePath = shift;
my $sendMailbat = shift;
my $FilesToProcess = shift;
my $myDateOverride = shift;
#25
my $myLastDayOverride = shift;
my $getFilesInd=shift;
my $debugInd=shift;
#================================
# Input Parameters End
#================================
#----------------------------------------------
#these variables need to be known in routines
my $dbh;
my $myLastDay;
my $send_scp_bat = "send_scp.bat";
my $send_scp_mach_bat = "send_scp_mach.bat";
my $thisProgram="CustomerGenericProcedure.pl";
my $fileDbStatus;
#Send to MACH server ind
my $SEND_TO_MACH='M';
my $SEND_TO_CUST='C';
my $SEND_TO_BOTH='B';
my $IND_YES = 'Y';
my $IND_NO = 'N';
my $FILE_NEW='1';
my $FILE_IN_PROCESS='2';
my $FILE_SUCCESS='3';
my $FILE_CUST_SCP_ERR='7';
my $FILE_MACH_SCP_ERR='9';
my $STS_WARNING='W';
my $STS_ERROR='E';
my $STS_INFO='I';
my $flow_type;
my $FLOW_CUSTOMER='Customer';
my $FLOW_MACH='MACH';
my $rerun_ind='';
#----------------------------------------------
#===================================================
#sub routines Start
#===================================================
sub genrate_report
{
my $reportFile=shift;
my $locGateId=shift;
my $locRepId=shift;
my $locMyDate=shift;
my $locLogFile=shift;
my $repRetCode=0;
my $errorCount=0;
my $warningCount=0;
my $Logline;
###start writing the report.
unlink $reportFile;
sleep 1;
$repRetCode=open(MyRepFile,">>".$reportFile) or die("Could not open Report file: ".$reportFile);
print MyRepFile "----I---- This is an Error log report for customer:".$locGateId."\n";
print MyRepFile "----I---- Run date is :".$locMyDate."\n";
print MyRepFile "----I---- The following lines are log extraction from :\n";
print MyRepFile "----I---- log text file: ".$locLogFile."\n";
print MyRepFile "----I---- database log\n";
print MyRepFile "----I---- The first part is the database log\n";
my $Rsth=$dbh->prepare('select module,msg_date,msg_text from ext_tap_rep where origin_gate_id=? and repid=? and msg_text!=?');
my @RepArray;
$Rsth->execute($locGateId,$locRepId,"Starting procedure");
my $Module = '';
my $MsgDate = '';
my $MsgText = '';
while (@RepArray = $Rsth->fetchrow_array())
{
$Module = $RepArray[0] // 'Undefined';
$MsgDate = $RepArray[1] // 'Undefined';
$MsgText=$RepArray[2] // 'Undefined';
print MyRepFile "----E---- Database error occurred in module: ".$Module. " at: " .$MsgDate ." The error is: ".$MsgText."\n";
$errorCount=$errorCount+1;
}
$Rsth->finish();
print MyRepFile "----I---- Text log file\n";
open(myOldLog,$locLogFile);
while(<myOldLog>)
{
$Logline=$_;
if ($Logline =~ m/----E----/)
{
print MyRepFile $Logline;
$errorCount=$errorCount+1;
}
if ($Logline =~ m/----W----/)
{
$warningCount=$warningCount+1;
}
}
print MyRepFile "----I---- Total of ".$errorCount." Errors occured \n";
print MyRepFile "----I---- Total of ".$warningCount." Warnings occured \n";
print MyRepFile "----I---- End of report file \n";
close (MyRepFile);
return $errorCount;
}
#######################################################################################
#####A subroutine to create the sh file for the filelist scp###########################
#######################################################################################
sub create_filelist_bash_file
{
my $OrigGateId = shift;
my $IPAddress = shift;
my $FTPUsr = shift;
my $indir = shift;
my $RemDir = shift;
my $bashFile="send_file_list.sh";
unlink $bashFile;
my $mycmd = "scp -Bq ".$customerRootFolderLin."/"."sent_file_list"."/".$SentFileListFileName."_".$myLastDay."\.txt"." ".$FTPUsr."\@".$IPAddress.":".$RemDir.$SentFileListFileName."_".$myLastDay."\.txt";
open(MYFILE,">>".$bashFile);
print MYFILE $mycmd;
close (MYFILE);
}
#######################################################################################
#####A subroutine to create the sh file for te scp ####################################
#######################################################################################
sub create_scp_bash_file
{
my $OrigGateId = shift;
my $IPAddress = shift;
my $FTPUsr = shift;
my $indir = shift;
my $RemDir = shift;
my $machInd = shift;
my $bashFile='';
#local($OrigGateId,$IPAddress,$FTPUsr,$indir,$remDIR)=($_[0],$_[1],$_[2],$_[3],$_[4]);
if ($machInd eq $IND_NO){
$bashFile="send_scp.sh";
}else{
$bashFile="send_scp_mach.sh";
}
unlink $bashFile;
my $mycmd = "scp -Bq ".$indir."\$1"." ".$FTPUsr."\@".$IPAddress.":".$RemDir."\$1";
open(MYFILE,">>".$bashFile);
print MYFILE $mycmd;
close (MYFILE);
return 1;
}
#######################################################################################
#####A subroutine to send a file using SCP ############################################
#######################################################################################
sub SCPFile{
my $FileNameText = shift;
my $isMachInd = shift;
my $rerun_ind = shift;
my $BatchFile="";
my $locRetCode;
my $msgLevel;
my $msgTarget;
# for debug
#print MyLog "isMachInd: ".$isMachInd."\n";
##call the batch file
# Changed the "else" to "elsif" - Yoni 15.08.2014
if ($isMachInd eq $IND_NO){
$BatchFile=$customerRootFolderWin.'\\'.$send_scp_bat;
}elsif ($isMachInd eq $IND_YES) {
$BatchFile=$customerRootFolderWin.'\\'.$send_scp_mach_bat;
}else{
print MyLog "----E---- Unexpected value inside mathod SCPFile for parameter isMachInd. Value: ".$isMachInd."\n";
return 0;
}
#for debug:
# print MyLog "----I---- Running SCP command with parameters: ".$BatchFile." , ".$FileNameText."\n";
my @SendArg=($BatchFile,$FileNameText);
$locRetCode=system(@SendArg);
#return code 0 - all is OK
if ($locRetCode==0) {
return 1;
}else {
$msgLevel = "W";
if ($isMachInd eq $IND_NO){
$msgTarget = "Customer";
}else{
$msgTarget = "MACH";
}
print MyLog "----".$msgLevel."---- Failed to scp file ".$FileNameText." to ".$msgTarget." with script ".$BatchFile."\n";
print MyLog "----I---- Going to sleep 20 seconds and then retry"."\n";
#try again after 20 seconds
sleep 20;
#print MyLog "----I---- msgLevel = ".$msgLevel."\n";
#print MyLog "----I---- rerun_ind = ".$rerun_ind."\n";
$locRetCode=system(@SendArg);
if ($locRetCode==0) {
return 1;
}else{
#set the error to E - only for rerun.
if ($rerun_ind eq $IND_YES ){
$msgLevel = "E";
}
print MyLog "----".$msgLevel."---- Failed to scp file ".$FileNameText." to ".$msgTarget." with script ".$BatchFile."\n";
return 0;
}
}
}
sub scp_file_list
{
my $FileNameText = shift;
#local($FileNameText)=($_[0]);
##call the batch file
my $cmd=$FileNameText;
system($cmd);
}
#######################################################################################
##### A subroutine handle return status from SCP file ########
#######################################################################################
sub handleRetCodeFromScp{
my $retCode = shift;
my $FileNameText = shift;
my $SentFileListFile = shift;
my $flow_type = shift;
my $sendToCustInd = shift;
my $sendToMachInd = shift;
my $rerun_ind = shift;
my $returnStatus;
my $msg_text='';
my $msg_severity='';
if ($debugInd eq "Y"){print MyLog "----D---- Handling return status for file ".$FileNameText."\n";}
if ($debugInd eq "Y"){print MyLog "----D---- sendToCustInd = ".$sendToCustInd." sendToMachInd = ".$sendToMachInd."\n";}
if ($debugInd eq "Y"){print MyLog "----D---- flow_type = ".$flow_type."\n";}
if ($flow_type eq $FLOW_CUSTOMER){
$msg_text="Customer";
}elsif ($flow_type eq $FLOW_MACH){
$msg_text="MACH";
}else{
$msg_text=$flow_type;
print MyLog "----I---- Unexpected value in flow_type = ".$flow_type."\n";
}
if ($rerun_ind eq $IND_YES ){
$msg_severity='E';
}else{
$msg_severity='W';
}
if ($retCode !=1 ){
print MyLog "----".$msg_severity."---- Can't scp file ".$FileNameText." to ".$msg_text."\n";
$returnStatus=0;
}else{
print MyLog "----I---- File ".$FileNameText." was sent to ".$msg_text."\n";
if (
(($sendToCustInd eq 'Y') && ($flow_type eq $FLOW_CUSTOMER))
||
(($sendToCustInd eq 'N') && ($flow_type eq $FLOW_MACH) && ($sendToMachInd eq 'Y'))
){
if ($debugInd eq "Y"){print MyLog "----D---- Adding file to ".$SentFileListFile."\n";}
##insert the files into the sent files List file
open(textFile,">>".$SentFileListFile);
print textFile $FileNameText.";\n";
close(textFile);
}else{
if ($debugInd eq "Y"){print MyLog "----D---- Skip Adding file to ".$SentFileListFile."\n";}
}
$returnStatus=1;
}
return $returnStatus;
}
#######################################################################################
#####A subroutine to to get the send type protocol of the gate and directories ########
#######################################################################################
sub GetDirData
{
# local ($gate_id)=($_[0]);
my $GateID=$_[0];
my $SendType; my $inpDir; my $outDir; my $repdir;
#my $sql = qq{select send_type,input_directory,output_directory,report_directory from tap_customer where customer_id=?};
my $sql = qq{select send_type,input_directory,report_directory from tap_customer where CUSTOMER_ID = ?};
my $sth=$dbh->prepare($sql);
$sth->execute($GateID);
#$sth->bind_columns(undef,\$SendType,\$inpDir,\$outDir,\$repdir);
$sth->bind_columns(undef,\$SendType,\$inpDir,\$repdir);
$sth->fetch();
$sth->finish();
#return ($SendType,$inpDir,$outDir,$repdir);
return ($SendType,$inpDir,$repdir);
}
############################################################################
#####A subroutine to to get the FTP data of the gate########
############################################################################
sub GetFtpData
{
my $gate_id=shift;
my $SendType=shift;
my $LIPAddress;
my $FTPUser;
my $FtpPass;
my $emaAddr;
my $ftpDir;
my $machServer;
my $machUser;
my $machRemoteDir;
my $sendToCustInd;
my $sendToMachInd;
my $sql;
my $sth;
if ($SendType eq "SCP" ){
$sql = qq{SELECT ip_address,user_name,pass,remote_dir, mach_server, mach_user, mach_remote_dir, send_to_cust_ind, send_to_mach_ind FROM tap_send_parameters WHERE origin_gate_id=? and send_type=?};
#$sql = qq{select ip_address,user_name,pass,remote_dir, from tap_send_parameters where origin_gate_id=? and send_type=?};
$sth=$dbh->prepare($sql);
$sth->execute($gate_id,"SCP");
$sth->bind_columns(undef,\$LIPAddress,\$FTPUser,\$FtpPass,\$ftpDir,\$machServer,\$machUser,\$machRemoteDir,\$sendToCustInd,\$sendToMachInd);
#$sth->bind_columns(undef,\$LIPAddress,\$FTPUser,\$FtpPass,\$ftpDir);
$sth->fetch();
$sth->finish();
return ($LIPAddress,$FTPUser,$FtpPass,$ftpDir,$machServer,$machUser,$machRemoteDir,$sendToCustInd,$sendToMachInd);
#return ($LIPAddress,$FTPUser,$FtpPass,$ftpDir);
}
}
############################################################################
#####A subroutine to update the status of the TAP_FILE_CREATED_TABLE########
############################################################################
sub updateTAPFileTable
{
my $newstat=shift;
my $gateId=shift;
my $FileName=shift;
my $doc=shift;
my $sql = qq{update tap_file_created set status=? where customer_id=? and file_name=? and date_of_call=?};
#print MyLog "----I---- Running SQL: ".$sql." with parameters: ".$newstat." , ".$gateId." , ".$FileName." , ".$doc."\n";
my $sth=$dbh->prepare($sql);
$sth->execute($newstat,$gateId,$FileName,$doc);
$dbh->commit;
$sth->finish();
return 1;
}
############################################################################
#####A subroutine to get the current date ##################################
############################################################################
sub getDate
{
use Time::gmtime;
my $tm=gmtime; my $day; my $month; my $year;
($day,$month,$year) = (gmtime) [3,4,5];
my $locDate=sprintf("%04d%02d%02d",$tm->year+1900,($tm->mon)+1,$tm->mday);
return $locDate;
}
sub getLastDay
{
my $sql = qq{select to_char(sysdate-1,'yyyymmdd') from dual};
my $sth=$dbh->prepare($sql);
$sth->execute();
my $lastday;
$sth->bind_columns(undef,\$lastday);
$sth->fetch();
$sth->finish();
return $lastday;
}
############################################################################
#####A subroutine to update the status table################################
############################################################################
sub updateStatusTable
{
my $stat_id = shift; my $gateId = shift;
#local $stat_id=$_[0];
#local $gateId=$_[1];
my $sql = qq{update ext_tap_status set status_id=? where origin_gate_id=?};
my $sth=$dbh->prepare($sql);
$sth->execute($stat_id,$gateId);
$dbh->commit;
$sth->finish();
}
############################################################################
#####A subroutine to update the status table################################
############################################################################
sub updateRepTable
{
my $myGate = shift; my $RepId = shift; my $module = shift; my $text = shift; my $doc = shift;
#local($myGate,$RepId,$module,$text,$doc)=($_[0],$_[1],$_[2],$_[3],$_[4]);
my $sql = qq{insert into ext_tap_rep values(?,?,?,?,?,?)};
my $sth=$dbh->prepare($sql);
$sth->execute($RepId,$module,undef,$text,$myGate,$doc);
$dbh->commit;
$sth->finish();
}
############################################################################
#####A subroutine to get the relevant repId#################################
############################################################################
sub getRepID
{
my $LoOriginGateID = shift;
my $LrepID;
#$LoOriginGateID=$_[0];
my $sql = qq{select NVL(max(repid),1) as repid from ext_tap_rep where origin_gate_id=?};
my $sth=$dbh->prepare($sql);
$sth->execute($LoOriginGateID);
$sth->bind_columns(undef,\$LrepID);
$sth->fetch();
$sth->finish();
return $LrepID;
}
############################################################################
#####A subroutine to check how many files we got from the collection #######
############################################################################
sub getNumOfFiles
{
my $file_dir = shift; my $File_Format = shift;
my $count=0;
my @list_of_files = <$file_dir$File_Format>;
foreach(@list_of_files)
{
$count=$count+1;
}
return $count;
}
##############################################################################
#####A subroutine to check how many files we should expect to have and send##
##############################################################################
sub getNumOfDBFiles
{
my $mOrigGid = shift;
my $num_of_files;
#$mOrigGid=$_[0];
my $sql = qq{select num_of_files from TAP_FILE_TO_PROCESS where origin_gate_id=?};
my $sth=$dbh->prepare($sql);
$sth->execute($mOrigGid);
$sth->bind_columns(undef,\$num_of_files);
$sth->fetch();
$sth->finish();
return $num_of_files;
}
###############################################################################
#####A subroutine to check the status table in the database every phase will###
#####continue only if the appropiate staus is in the database table############
###############################################################################
sub check_db_status
{
my $lOrigGid=shift;
#$lOrigGid=$_[0];
my $sql = qq{select status_id from ext_tap_status where origin_gate_id=?};
my $sth=$dbh->prepare($sql);
$sth->execute($lOrigGid);
my $status_id;
$sth->bind_columns(undef,\$status_id);
$sth->fetch();
$sth->finish();
return $status_id;
}
sub get_files
{
my $address=shift; my $username=shift; my $pass=shift; my $rem_dir=shift;
#local($address, $username, $pass, $rem_dir)= ($_[0], $_[1], $_[2],$_[3]);
my $FTPFileName = "ZippedTextFiles.zip";
my $ftp;
my $newerr=0;
$ftp=Net::FTP->new($address,Timeout=>240) or $newerr=1;
if ($newerr==1){
print MyLog "----E---- Cannot connect to server: ".$address."\n";
$ftp->quit;
return 0;
}
print MyLog "----I---- Connected to server ".$address."\n";
$ftp->login($username,$pass) or $newerr=1;
if ($newerr==1){
print MyLog "----E---- Cannot login with credentials: ".$username."/".$pass."\n";
$ftp->quit;
return 0;
}
print MyLog "----I---- Logged in to FTP server \n";
$ftp->cwd($rem_dir) or $newerr=1;
if ($newerr==1){
print MyLog "----E---- Cannot Change Directory to ".$rem_dir."\n";
$ftp->quit;
return 0;
}
print MyLog "----I---- Directory changed to ".$rem_dir."\n";
$ftp->binary;
$ftp->get($FTPFileName,$zippedDir.$FTPFileName) or $newerr=1;
if ($newerr==1){
print MyLog "----W---- "."Cannot get file ".$FTPFileName." from remote Directory: ".$rem_dir."\n";
sleep 5;
$newerr=0;
print MyLog "----I---- "."Going to sleep 5 seconds before second attempet to get file ".$FTPFileName." from remote Directory: ".$rem_dir."\n";
$ftp->get($FTPFileName,$zippedDir.$FTPFileName) or $newerr=1;
if ($newerr==1){
print MyLog "----E---- "."Cannot get file ".$FTPFileName." from remote Directory: ".$rem_dir."\n";
$ftp->quit;
return 0;
}
}
print MyLog "----I---- "."Successfully received file ".$FTPFileName." from remote Directory: ".$rem_dir."\n";
$ftp->delete($FTPFileName) or $newerr=1;
if ($newerr==1){
print MyLog "----E---- "."Cannot delete file ".$FTPFileName."\n";
$ftp->quit;
return 0;
}
print MyLog "----I---- ".$FTPFileName." successfully deleted \n";
$ftp-> quit;
return 1;
}
sub sendSummaryMail{
my $sendMailbat=shift;
my $logFile=shift;
my $reportFile=shift;
my @mailArg;
@mailArg=($sendMailbat,$logFile, $reportFile);
sleep 1;
system(@mailArg);
}
#===================================================
#sub routines End
#===================================================
#==========================================
# main()
#==========================================
my $sendFileListFileInd='N';
my $procStatus=1;
my $RetCode='';
my $GET_FILES_N='N';
my $GET_FILES_Y='Y';
print ("customerRootFolderWin: ".$customerRootFolderWin."\n\n");
#==========================================
#Set run dates
#==========================================
#$myDate - is used to match entries in DB
#$myLastDay - is used to set the date in SentFileListAUTMX_%DATE%.txt
my $myDate;
my $serverDate=getDate();
if ($myDateOverride.'A' eq 'A'){
$myDate=getDate();
}else{
$myDate=$myDateOverride;
}
my $reportFile= $RepFilePath."RepErrFile_".$myGate."_".$myDate.".log";
#---------------------------------------
# Open Logfile
#---------------------------------------
open (MyLog,">>".$logFile);
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- Starting TAP process for ".$myDate." for Customer ".$myGate."\n";
print MyLog "----I---- Processing files from day: ".$myDate."\n";
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- Run Mode: ".$run_mode."\n";
print MyLog "----I---- Get Files [Y/N] : ".$getFilesInd."\n";
print MyLog "----I---- Source files: ".$os_user."/".$os_pass."@".$host_ip."\n";
print MyLog "----I---- DB connection: ".$db_username."/".$db_pass."@".$user_string."\n";
print MyLog "----I---- Mail script: ".$sendMailbat."\n";
print MyLog "----I---- Report File: ".$reportFile."\n";
print MyLog "----I---- Debug Ind: ".$debugInd."\n";
print MyLog "----I---- ---------------------------------"."\n";
if ($myDate ne $serverDate){
print MyLog "----I---- Run Date is manually set to a diffrerent date than today!!!"."\n";
print MyLog "----I---- Run Date: ".$myDate." Today: ".$serverDate."\n";
print MyLog "----I---- ---------------------------------"."\n";
}
#---------------------------------------
# Open Database Connection
#---------------------------------------
print MyLog "----I---- Opening Database Connection ".$user_string."@".$db_username."\n";
$dbh=DBI->connect($user_string,$db_username,$db_pass,{RaiseError =>1,AutoCommit=>0})||die "$DBI::errstr";
print MyLog "----I---- Database Connection Opened"."\n";
#---------------------------------------
# get SYSDATE from DB
#---------------------------------------
#$myLastDay - is used to set the date in SentFileList_%DATE%.txt
if ($myLastDayOverride.'A' eq 'A'){
$myLastDay=getLastDay();
}else{
$myLastDay=$myLastDayOverride;
}
print MyLog "----I---- Generating files with TIMESTAMP : ".$myLastDay."\n";
##############################################################################
###get the repid for this process this will be used later on in all updates###
##############################################################################
print MyLog "----I---- Call the database to get RepID \n";
my $repId=getRepID($myGate);
if ($repId eq ""){
print MyLog "----E---- Can't get the database repId from Table EXT_TAP_REP for Customer: ".$myGate."\n";
}
################################################################################################################
##Now check the status for sucess if the status is 1 then the procedure succeeded and the the next phase can####
##The next stage is sending the files through FTP from the collection gateway to the BDS########################
################################################################################################################
print MyLog "----I---- Call check_db_status in EXT_TAP_STATUS with customer_id: ".$myGate."\n";
my $db_status=check_db_status($myGate);
print MyLog "----I---- Got status: ".$db_status."\n";
if ($db_status == 1 )
{
##############################################################################################################
###File creation in the database went fine ftp to the bds can start now the status table will be updated#######
##############################################################################################################
my $myFiles;
if ($getFilesInd eq $GET_FILES_Y){
print MyLog "----I---- Getting the files from the database server ".$host_ip." from path: ".$os_tap_files_path."\n";
$myFiles=get_files($host_ip,$os_user,$os_pass,$os_tap_files_path);
}else{
print MyLog "----I---- GET_FILES_IND is set to N. Skipping ftp of new ZippedTextFiles.zip"."\n";
$myFiles=1;
}
if ($myFiles!=1)
{
print MyLog "----E---- Can't get the files from the database server \n";
print MyLog "----E---- Failed to bring files from server: ".$host_ip." path: ".$os_tap_files_path." user/pass: ".$os_user."/".$os_pass."\n";
print MyLog "----E---- Program ".$thisProgram." Terminated with Error"."\n";
close(MyLog);
genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
sendSummaryMail($sendMailbat,$logFile,$reportFile);
$dbh->disconnect;
exit 0;
}
#in the new configuration we bring the files zipped so we need to open it
my $ret1=0;
if ($getFilesInd eq $GET_FILES_Y){
print MyLog "----I---- Running unzip command : ".$unzip_cmd."\n";
$ret1=system($unzip_cmd);
}else{
#TEST!!!
$ret1=0;
}
if ($ret1 !=0)
{
print MyLog "----E---- Unzip command failed: ".$unzip_cmd."\n";
print MyLog "----E---- Cannot unzip the files \n";
print MyLog "----E---- Program ".$thisProgram." Terminated with Error"."\n";
close(MyLog);
genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
sendSummaryMail($sendMailbat,$logFile,$reportFile);
$dbh->disconnect;
exit 0;
}
########################################################################
##We are after getting the files now we have to do the following########
##1.check that we got all the needed files##############################
##2.update the status table#############################################
########################################################################
my $num_of_files=0;
my $myNumOfTransferedFiles=0;
if ($getFilesInd eq $GET_FILES_Y){
$num_of_files=getNumOfDBFiles($myGate);
$myNumOfTransferedFiles=getNumOfFiles($customerRootFolder."/".$filesFolder."/","CD*");
print MyLog "----I---- Number of Files from Database (TAP_FILE_TO_PROCESS) for gate: ".$myGate.": ".$num_of_files."\n";
print MyLog "----I---- Number of Files from Zip File: ".$myNumOfTransferedFiles."\n";
}else{
print MyLog "----I---- Skip Compare of Number of Files from Database (TAP_FILE_TO_PROCESS) to Files from gate ".$myGate."\n";
$num_of_files=1;
$myNumOfTransferedFiles=1;
}
if ($num_of_files != $myNumOfTransferedFiles)
{
###The number of files are not equal to the number of files prepared by the db####
###In this case we should look for the missing files and try to rftp it###########
###This will be handled later meanwhile we will do the follwing###################
###1.update_status_table##########################################################
###2.update report table##########################################################
###3.send mail####################################################################
###4.send mib to the HPOV#########################################################
###5.exit#########################################################################
print MyLog "----E---- The number of files created in the DB is not equal to the files FTPd to the BDS"."\n";
print MyLog "----E---- The number of files from DB (TAP_FILE_TO_PROCESS) for origin_gate_id = ".$myGate." = ".$num_of_files."\n";
print MyLog "----E---- The number of files from ZippedTextFiles.zip: ".$myNumOfTransferedFiles."\n";
print MyLog "----E---- Program ".$thisProgram." Terminated with Error"."\n";
updateStatusTable("9",$myGate);
updateRepTable($myGate,
$repId,
"ComapringNumOfFiles",
"The number of files created in the DB is not equal to the files FTPd to the BDS",
$myDate);
close(MyLog);
genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
sendSummaryMail($sendMailbat,$logFile,$reportFile);
$dbh->disconnect;
die;
}
else ##the number of files are fit.
{
###########################################################################################################
##IF the number of files is o.k we need to do the following################################################
##
##2.Call the converter#####################################################################################
##3.Check that all taps were created ######################################################################
##4.Parse the allround logs to discover errors#############################################################
##5.SCP the TAP files to the customer #####################################################################
##6.Create a file containing the names of all the TAP files created########################################
##7.SCP The file to the designated directory###############################################################
###########################################################################################################
my $SndType;
my $inDir;
my $ouDir;
my $IPAddress;
my $FTPUsr;
my $FtpPassw;
my $RemFTPDir;
my $machServer;
my $machUser;
my $machRemoteDir;
my $sendToCustInd;
my $sendToMachInd;
my $repDir;
my $retCode;
print MyLog "----I---- Preparing files to sending \n";
##do all one time things
##Get the ftp directory data for the customer###
#($SndType,$inDir,$ouDir,$RepDir)=GetDirData($myGate);
($SndType,$inDir,$repDir)=GetDirData($myGate);
##Get the FTP data of the gateId###
if ($SndType eq "SCP"){
# Moved here by Yoni - 15.08.2014
#($IPAddress,$FTPUsr,$FtpPassw,$RemFTPDir)=GetFtpData($myGate,"SCP");
($IPAddress,$FTPUsr,$FtpPassw,$RemFTPDir,$machServer,$machUser,$machRemoteDir,$sendToCustInd,$sendToMachInd)=GetFtpData($myGate,"SCP");
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- SCP Details"."\n";
print MyLog "----I---- Send to MACH: ".$sendToMachInd."\n";
print MyLog "----I---- Send to Customer: ".$sendToCustInd."\n";
print MyLog "----I---- MACH Remote Server Details. Server: ".$machServer." User: ".$machUser." Remote Dir: ".$machRemoteDir."\n";
print MyLog "----I---- Customer Remote Server Details. Server: ".$IPAddress." User: ".$FTPUsr." Remote Dir: ".$RemFTPDir."\n";
print MyLog "----I---- ---------------------------------"."\n";
if ($sendToCustInd eq $IND_YES){
#if (($sendToMachInd eq $SEND_TO_CUST) || ($sendToMachInd eq $SEND_TO_BOTH)){
print MyLog "----I---- Creating SCP bash file."."\n";
$retCode=create_scp_bash_file($myGate,$IPAddress,$FTPUsr,$inDir,$RemFTPDir,$IND_NO);
if ($retCode!=1)
{
print MyLog "----E---- Creation of scp bash file failed. The files will not be sent \n";
print MyLog "----E---- Program ".$thisProgram." Terminated with Error"."\n";
close(MyLog);
genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
sendSummaryMail($sendMailbat,$logFile,$reportFile);
$dbh->disconnect;
die;
}
print MyLog "----I---- SCP bash created."."\n";
}
if ($sendToMachInd eq $IND_YES){
#if (($sendToMachInd eq $SEND_TO_MACH) || ($sendToMachInd eq $SEND_TO_BOTH)){
print MyLog "----I---- Creating MACH SCP bash file."."\n";
$retCode=create_scp_bash_file($myGate,$machServer,$machUser,$inDir,$machRemoteDir,$IND_YES);
if ($retCode!=1)
{
print MyLog "----E---- Creation of MACH scp bash file failed. The files will not be sent \n";
print MyLog "----E---- Program ".$thisProgram." Terminated with Error"."\n";
close(MyLog);
genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
sendSummaryMail($sendMailbat,$logFile,$reportFile);
$dbh->disconnect;
die;
}
print MyLog "----I---- MACH SCP bash created."."\n";
}
}
##Move over all the TAP files call the converter for each file.
##find the relevant data to call the converter for this file.
print MyLog "----I---- Looking for files in TAP_FILE_CREATED WHERE customer_id=".$myGate." AND status=1 and date_of_call =".$myDate."\n";
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- Starting Loop for status=1"."\n";
print MyLog "----I---- ---------------------------------"."\n";
$rerun_ind=$IND_NO;
my $SentFileListFile=$customerRootFolderWin."\\sent_file_list\\".$SentFileListFileName."_".$myLastDay.".txt";
#create the file list to move to the input directory of the converter
#my $FNsth=$dbh->prepare('select file_name from tap_file_created where customer_id=? and status=1');
my $FNsth=$dbh->prepare('select file_name from tap_file_created where customer_id=? and status=1 and date_of_call =?');
my @FileArray;
#Create $SentFileListFile
open(textFile,">>".$SentFileListFile);
close(textFile);
open(FTProc,">>".$FilesToProcess);
$FNsth->execute($myGate,$myDate);
my $fileHandleCounter=0;
while (@FileArray = $FNsth->fetchrow_array())
{
my $FileNameText = $FileArray[0];
#copy the file to the converter input dir.
print FTProc $FileNameText."\n";
print MyLog "----I---- Handling File: ".$FileNameText."\n";
$retCode=move($customerRootFolderWin."\\".$filesFolder."\\".$FileNameText,$convInDir."\\".$FileNameText);
if ($retCode !=1)
{
print MyLog "----E---- Error handling file ".$FileNameText."\n";
print MyLog "----E---- Command Failed: "."move(".$customerRootFolderWin."\\".$filesFolder."\\".$FileNameText." , ".$convInDir."\\".$FileNameText.")"."\n";
}
else
{
####PLEASE UNMARK WHEN ON PRODUCTION
sleep 3;
my $cmd=$customerRootFolder."/"."taptext_tap310_converter/run_taptext_tap310_converter_local.bat"." ".$customerRootFolder."/"."taptext_tap310_converter/";
$retCode=system($cmd);
if ($retCode!=0)
{
print MyLog "----E---- Can't activate the converter for file ".$FileNameText." \n";
print MyLog "----E---- Command Failed: ".$cmd." \n";
}
else
{
##the status for each processed file should be updated to 2 which means converted
$retCode=updateTAPFileTable("2",$myGate,$FileNameText,$myDate);
if ($retCode!=1)
{
print MyLog "----E---- can't update ".$FileNameText." status in the database process stops\n";
print MyLog "----E---- Program ".$thisProgram." Terminated with Error"."\n";
close(MyLog);
genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
sendSummaryMail($sendMailbat,$logFile,$reportFile);
$dbh->disconnect;
die;
}
else
{
#print MyLog "----I---- File ".$FileNameText." status updated to 2"."\n";
##now send the file
sleep 1;
if ($SndType eq "SCP"){
$procStatus=1;
if ($sendToCustInd eq $IND_YES){
#if (($sendToMachInd eq $SEND_TO_CUST) || ($sendToMachInd eq $SEND_TO_BOTH)){
#Send to Customer
$retCode=SCPFile($FileNameText,$IND_NO,$rerun_ind);
$flow_type=$FLOW_CUSTOMER;
if ($debugInd eq "Y"){print MyLog "----D---- After SCPFile for file : ".$FileNameText." got return status: ".$retCode."\n";}
$procStatus=handleRetCodeFromScp($retCode,$FileNameText,$SentFileListFile,$flow_type,$sendToCustInd,$sendToMachInd,$rerun_ind);
if ($debugInd eq "Y"){print MyLog "----D---- After handleRetCodeFromScp for file : ".$FileNameText." got return status: ".$procStatus."\n";}
if ($procStatus==1){
$sendFileListFileInd='Y';
$fileDbStatus=$FILE_SUCCESS;
}else{
$fileDbStatus=$FILE_CUST_SCP_ERR;
}
}
#if sentToCust took place and failed - do not continue
if ($procStatus==1){
if ($sendToMachInd eq $IND_YES){
#if (($sendToMachInd eq $SEND_TO_MACH) || ($sendToMachInd eq $SEND_TO_BOTH)){
#Send to MACH
$retCode=SCPFile($FileNameText,$IND_YES,$rerun_ind);
$flow_type=$FLOW_MACH;
if ($debugInd eq "Y"){print MyLog "----D---- After SCPFile for file : ".$FileNameText." got return status: ".$retCode."\n";}
$procStatus=handleRetCodeFromScp($retCode,$FileNameText,$SentFileListFile,$flow_type,$sendToCustInd,$sendToMachInd,$rerun_ind);
if ($debugInd eq "Y"){print MyLog "----D---- After handleRetCodeFromScp for file : ".$FileNameText." got return status: ".$procStatus."\n";}
if ($procStatus==1){
$sendFileListFileInd='Y';
$fileDbStatus=$FILE_SUCCESS;
}else{
$fileDbStatus=$FILE_MACH_SCP_ERR;
}
}
}
if ($debugInd eq "Y"){print MyLog "----D---- Updating File Status in DB. File : ".$FileNameText." Status: ".$fileDbStatus."\n";}
updateTAPFileTable($fileDbStatus,$myGate,$FileNameText,$myDate);
}#send type
}#update tap table
}#converter
} #move file
$fileHandleCounter = $fileHandleCounter + 1;
} #main file while
close(FTProc);
$FNsth->finish();
if (tell(MyLog) != -1){
print MyLog "----I---- Finished TAP files converter"."\n";
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- Number of handled Files (status 1): ".$fileHandleCounter."\n";
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- Before re-run loop"."\n";
print MyLog "----I---- handle files with status IN (7,9) for Customer=".$myGate." and date_of_call=".$myDate."\n";
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- Starting Loop for status = 7 or 9"."\n";
print MyLog "----I---- ---------------------------------"."\n";
}
$rerun_ind=$IND_YES;
$fileHandleCounter = 0;
my $fileCounterStsCustErr = 0;
my $fileCounterStsMachErr = 0;
## New section to handle any files remaining in STATUS=7 or 9
## We will re-run these files and hope that the second time they are sent successfully...
#$FNsth=$dbh->prepare('select file_name from tap_file_created where customer_id=? and status IN (7,9) and date_of_call=?');
$FNsth=$dbh->prepare('select file_name, status from tap_file_created where customer_id=? and status IN (7,9) and date_of_call=?');
$FNsth->execute($myGate,$myDate);
while (@FileArray = $FNsth->fetchrow_array())
{
my $FileNameText = $FileArray[0];
my $fileStatus = $FileArray[1];
print MyLog "----I---- Currently re-running file: ".$FileNameText." with status: ".$fileStatus."\n";
if ($fileStatus eq $FILE_CUST_SCP_ERR){
$fileCounterStsCustErr = $fileCounterStsCustErr + 1;
}else{
$fileCounterStsMachErr = $fileCounterStsMachErr + 1;
}
#copy the file to the converter input dir from the processed dir
my $retCode=move($convProcDir."\\".$FileNameText.".success",$convInDir."\\".$FileNameText);
#print MyLog "----I---- Moving File: ".$convProcDir."\\".$FileNameText.".success"." to: ".$convInDir."\\".$FileNameText."\n";
if ($retCode !=1)
{
print MyLog "----E---- Error handling file ".$FileNameText."\n";
print MyLog "----E---- Command Failed: "."move(".$convProcDir."\\".$FileNameText.".success",$convInDir."\\".$FileNameText.")"."\n";
}
else
{
sleep 1;
my $cmd=$customerRootFolder."/"."taptext_tap310_converter/run_taptext_tap310_converter_local.bat"." ".$customerRootFolder."/"."taptext_tap310_converter/";
$retCode=system($cmd);
if ($retCode!=0)
{
print MyLog "----E---- Can't activate the converter for file ".$FileNameText." \n";
print MyLog "----E---- Command Failed: ".$cmd." \n";
}
else
{
##the status for each processed file should be updated to 2 which means converted
$retCode=updateTAPFileTable("2",$myGate,$FileNameText,$myDate);
if ($retCode!=1)
{
print MyLog "----E---- can't update ".$FileNameText." status in the database process stops \n";
print MyLog "----E---- Program ".$thisProgram." Terminated with Error"."\n";
close(MyLog);
genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
sendSummaryMail($sendMailbat,$logFile,$reportFile);
$dbh->disconnect;
die;
}
else{
##now send the file
sleep 1;
if ($SndType eq "SCP")
{
$procStatus=1;
if ($sendToCustInd eq $IND_YES){
#if (($sendToMachInd eq $SEND_TO_CUST) || ($sendToMachInd eq $SEND_TO_BOTH)){
#Resend to Customer
if ($fileStatus eq $FILE_CUST_SCP_ERR){
$retCode=SCPFile($FileNameText,$IND_NO,$rerun_ind);
$flow_type=$FLOW_CUSTOMER;
if ($debugInd eq "Y"){print MyLog "----D---- After SCPFile for file : ".$FileNameText." got return status: ".$retCode."\n";}
$procStatus=handleRetCodeFromScp($retCode,$FileNameText,$SentFileListFile,$flow_type,$sendToCustInd,$sendToMachInd,$rerun_ind);
if ($debugInd eq "Y"){print MyLog "----D---- After handleRetCodeFromScp for file : ".$FileNameText." got return status: ".$procStatus."\n";}
if ($procStatus==1){
$sendFileListFileInd='Y';
$fileDbStatus=$FILE_SUCCESS;
}else{
$fileDbStatus=$FILE_CUST_SCP_ERR;
}
}
}#End $SEND_TO_CUST
if ($procStatus==1){
if ($sendToMachInd eq $IND_YES){
#if (($sendToMachInd eq $SEND_TO_MACH) || ($sendToMachInd eq $SEND_TO_BOTH)){
#Resend to MACH
if ( ($fileStatus eq $FILE_CUST_SCP_ERR) || ($fileStatus eq $FILE_MACH_SCP_ERR) ){
#Send to MACH
$retCode=SCPFile($FileNameText,$IND_YES,$rerun_ind);
$flow_type=$FLOW_MACH;
if ($debugInd eq "Y"){print MyLog "----D---- After SCPFile for file : ".$FileNameText." got return status: ".$retCode."\n";}
$procStatus=handleRetCodeFromScp($retCode,$FileNameText,$SentFileListFile,$flow_type,$sendToCustInd,$sendToMachInd,$rerun_ind);
if ($debugInd eq "Y"){print MyLog "----D---- After handleRetCodeFromScp for file : ".$FileNameText." got return status: ".$procStatus."\n";}
if ($procStatus==1){
$sendFileListFileInd='Y';
$fileDbStatus=$FILE_SUCCESS;
}else{
$fileDbStatus=$FILE_MACH_SCP_ERR;
}
}
}
}#End send to SEND_TO_MACH
if ($debugInd eq "Y"){print MyLog "----D---- Updating File Status in DB. File : ".$FileNameText." Status: ".$fileDbStatus."\n";}
updateTAPFileTable($fileDbStatus,$myGate,$FileNameText,$myDate);
}#send type
}#update tap table
}#convert
} #move file
$fileHandleCounter = $fileHandleCounter + 1;
} #main file while
$FNsth->finish();
if (tell(MyLog) != -1){
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- Number of handled Files in re-run: ".$fileHandleCounter."\n";
print MyLog "----I---- Status 7 Files: ".$fileCounterStsCustErr."\n";
print MyLog "----I---- Status 9 Files: ".$fileCounterStsMachErr."\n";
print MyLog "----I---- ---------------------------------"."\n";
print MyLog "----I---- After re-run loop \n";
}
##after finishing the files array we need to do the following:
##1.send the filelist file to the designated directory.
##2.scan the converter logs for errors.
##3.scan the report table for errors
##4.make a rejected file list
##5.report all errors by mail.
print MyLog "----I---- Creating sent_file_list file with parameters: ".$myGate." , ".$IPAddress." , ".$FTPUsr." , ".$inDir." , ".$RemFTPDir."\n";
create_filelist_bash_file($myGate,$IPAddress,$FTPUsr,$inDir,$RemFTPDir);
if ($sendFileListFileInd eq 'Y'){
print MyLog "----I---- Sending ".$SentFileListFile." File."."\n";
if ($run_mode eq 'PROD'){
print MyLog "----I---- Running in ".$run_mode." mode. Executing ".$customerRootFolder."/"."send_filelist_scp.bat"."\n";
scp_file_list($customerRootFolder."/"."send_filelist_scp.bat");
print MyLog "----I---- Finished Executing ".$customerRootFolder."/"."send_filelist_scp.bat"."\n";
}else{
print MyLog "----I---- Running in ".$run_mode." mode. Executing ".$customerRootFolder."/"."send_filelist_scp_test.bat"."\n";
scp_file_list($customerRootFolder."/"."send_filelist_scp_test.bat");
print MyLog "----I---- Finished Executing ".$customerRootFolder."/"."send_filelist_scp_test.bat"."\n";
}
}
##Now get all the Errors from the Db report and write into a text file that will####
##be sent later on.
if (tell(MyLog) != -1){
print MyLog "----I---- #### END #### \n";
}
close(MyLog);
my $repErrorCount=genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
if ($repErrorCount > 0){
sendSummaryMail($sendMailbat,$logFile,$reportFile);
}
}
}
else
{
print MyLog "----E---- Error DB status for origin_gate_id ".$myGate." in EXT_TAP_STATUS is not Valid.\n";
print MyLog "----E---- Got Return Status: ".$db_status." When Running SQL: SELECT status_id from ext_tap_status where origin_gate_id = ".$myGate."\n";
print MyLog "----E---- Program ".$thisProgram." Terminated with Error"."\n";
close(MyLog);
genrate_report($reportFile,$myGate,$repId,$myDate,$logFile);
sendSummaryMail($sendMailbat,$logFile,$reportFile);
$dbh->disconnect;
die;
}
close(MyLog);
close(FTProc);
$dbh->disconnect;
==========================================
send_scp.shscp -Bq /cygdrive/d/MobilkomLieTaps/taptext_tap310_converter/output/$1 starhome@666.777.888.999:/ADXDATA/MACH/LIEMX/$1
send_scp_mach.sh
scp -Bq /cygdrive/d/MobilkomLieTaps/taptext_tap310_converter/output/$1 LIEMXV@888.222.111.444:/$1
send_file_list.sh
scp -Bq /cygdrive/d/MobilkomLieTaps/sent_file_list/SentFileLisLIEMX_20151104.txt starhome@666.777.888.999:/ADXDATA/MACH/LIEMX_312/SentFileLisLIEMX_20151104.txt
send_scp_late.sh
scp -Bq /cygdrive/d/MobilkomLieTaps/taptext_tap310_converter/output/CDALBM4LIEMX01154 LIEMXV@888.222.111.444:/CDALBM4LIEMX01154
activate_proc.bat
perl MobilkomLieMain.pl
d:\software\cygwin\bin\bash.exe --login /cygdrive/d/MobilkomLieTaps/send_scp.sh %1
send_scp_mach.bat
d:\software\cygwin\bin\bash.exe --login /cygdrive/d/MobilkomLieTaps/send_scp_mach.sh %1
sendMail.bat
blat MobLieMailBody.txt -to some.user@starhome.com -cc other.user@starhomemach.com -i from.user@starhome.com -subject "TAP conversion failure for Mobilkom (LIE)" -attacht %1 -attacht %2
MobLieMailBody.txt
Hi All,
A Fatal Erorr Occured during Mobilkom(LIE) text to TAP conversion.
Please look at the log files and contact MIS department.
Thanks
MIS Department
Starhome
No comments:
Post a Comment