fix errore chiamata gettimestamp
This commit is contained in:
@@ -346,11 +346,11 @@ sub emailSend {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
print getLoggingTime() . " - $email_obj\n";
|
print getTimeStamp("log") . " - $email_obj\n";
|
||||||
print getLoggingTime() . " - Mail sent to: $email_addr.\n";
|
print getTimeStamp("log") . " - Mail sent to: $email_addr.\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print getLoggingTime() . " - Error in sending mail to: $email_addr.\n";
|
print getTimeStamp("log") . " - Error in sending mail to: $email_addr.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,36 @@ my $ext = ".csv";
|
|||||||
my $hostname = "160.78.21.55";
|
my $hostname = "160.78.21.55";
|
||||||
my $username = 'asega';
|
my $username = 'asega';
|
||||||
my $password = 'mums';
|
my $password = 'mums';
|
||||||
|
my $lockTS;
|
||||||
|
my $lockfile = '/tmp/retransmit.lock';
|
||||||
|
|
||||||
GetOptions( "file=s" => \$readingFile )
|
GetOptions( "file=s" => \$readingFile,
|
||||||
or die("Error in command line arguments\n");
|
"lockts=i" => \$lockTS
|
||||||
|
) or die("Error in command line arguments\n");
|
||||||
|
|
||||||
|
if (-e $lockfile) {
|
||||||
|
my $content;
|
||||||
|
open(my $fh, '<', $lockfile) or die "cannot open file $lockfile";
|
||||||
|
{
|
||||||
|
local $/;
|
||||||
|
$content = <$fh>;
|
||||||
|
}
|
||||||
|
close($fh);
|
||||||
|
if ($content != $lockTS) {
|
||||||
|
print getTimeStamp("log") . " >> timestamp mismatch... $content - $lockTS ... Exiting. \n";
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
open(FH, '>', $lockfile) or die $!;
|
||||||
|
print FH $lockTS;
|
||||||
|
close(FH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index( $readingFile, 'ZZZZZZ.csv' ) > 0) {
|
||||||
|
unlink $lockfile;
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
print getTimeStamp("log") . " >> $readingFile \n";
|
print getTimeStamp("log") . " >> $readingFile \n";
|
||||||
|
|
||||||
@@ -50,7 +77,7 @@ my($dmy1, $dmy2, $dmy3, $unit, $dmy4) = split(/\//,$path);
|
|||||||
print getTimeStamp("log") . " >> Unit $unit - Filename $tool" . "$suffix \n";
|
print getTimeStamp("log") . " >> Unit $unit - Filename $tool" . "$suffix \n";
|
||||||
|
|
||||||
my $ftp = Net::FTP->new($hostname, Timeout => 20, Debug => 0, Passive => 0)
|
my $ftp = Net::FTP->new($hostname, Timeout => 20, Debug => 0, Passive => 0)
|
||||||
or warn getTimeStamp("log") . " >> Cannot connect to $hostname: $@";
|
or die getTimeStamp("log") . " >> Cannot connect to $hostname: $@";
|
||||||
if ($ftp->login($username,$password)) {
|
if ($ftp->login($username,$password)) {
|
||||||
if ($ftp->put($readingFile, $tool . $suffix)) {
|
if ($ftp->put($readingFile, $tool . $suffix)) {
|
||||||
print getTimeStamp("log") . " >> Put $readingFile completed.\n";
|
print getTimeStamp("log") . " >> Put $readingFile completed.\n";
|
||||||
@@ -60,10 +87,10 @@ if ($ftp->login($username,$password)) {
|
|||||||
print getTimeStamp("log") . " >> Moved $readingFile -> $send.\n";
|
print getTimeStamp("log") . " >> Moved $readingFile -> $send.\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn getTimeStamp("log") . " >> Put $readingFile failed ", $ftp->message;
|
die getTimeStamp("log") . " >> Put $readingFile failed ", $ftp->message;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn getTimeStamp("log") . " >> Cannot login ", $ftp->message;
|
die getTimeStamp("log") . " >> Cannot login ", $ftp->message;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user