Added ftp validate option flag to crontab scripts

git-svn-id: svn://192.168.202.10@1758 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2011-11-30 23:07:03 +00:00
parent 3ee4f9379f
commit 83ca0686aa
2 changed files with 48 additions and 6 deletions
+25 -4
View File
@@ -46,6 +46,7 @@
# 91123-0037 - Added FTP CLI options
# 110524-1049 - Added run-check concurrency check option
# 111128-1615 - Added Ftp persistence option
# 111130-1751 - Added Ftp validate option
#
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -71,6 +72,7 @@ $VARHTTP_path = 'http://10.0.0.4';
$file_limit = 1000;
$list_limit = 1000;
$FTPpersistent=0;
$FTPvalidate=0;
### begin parsing run-time options ###
if (length($ARGV[0])>1)
@@ -104,6 +106,7 @@ if (length($ARGV[0])>1)
print " [--ftp-pass=XXX] = FTP server password\n";
print " [--ftp-dir=XXX] = FTP server directory\n";
print " [--ftp-persistent] = Does not log out between every file transmission\n";
print " [--ftp-validate] = Checks for a file size on the file after transmission\n";
print "\n";
exit;
}
@@ -227,6 +230,12 @@ if (length($ARGV[0])>1)
if ($DB > 0)
{print "\n----- FTP PERSISTENT: $FTPpersistent -----\n\n";}
}
if ($args =~ /--ftp-validate/i)
{
$FTPvalidate=1;
if ($DB > 0)
{print "\n----- FTP VALIDATE: $FTPvalidate -----\n\n";}
}
}
}
else
@@ -360,9 +369,10 @@ foreach(@FILES)
$FILEsize2[$i] = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$dir2/$FILES[$i] $FILEsize2[$i]\n\n";}
if ($FILEsize1[$i] ne $FILEsize2[$i]) {
if ($FILEsize1[$i] ne $FILEsize2[$i])
{
if ($DBX) {print "not transfering $dir2/$FILES[$i]. File size mismatch $FILEsize2[$i] != $FILEsize1[$i]\n\n";}
}
}
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
@@ -434,6 +444,17 @@ foreach(@FILES)
}
$ftp->binary();
$ftp->put("$dir2/$ALLfile", "$ALLfile");
if ($FTPvalidate > 0)
{
$FTPfilesize = $ftp->size("$ALLfile");
if($DBX){print STDERR "FTP FILESIZE: $FTPfilesize/$FILEsize1[$i] | $ALLfile\n";}
if ( ($FILEsize1[$i] > 100) && ($FTPfilesize < 100) )
{
print "ERROR! File did not transfer, exiting: $FTPfilesize/$FILEsize1[$i] | $ALLfile\n";
exit;
}
}
if ($FTPpersistent < 1)
{
$ftp->quit;
@@ -452,8 +473,8 @@ foreach(@FILES)
if ( $transfered_files == $file_limit)
{
if($DBX){print STDERR "Transfer limit of $file_limit reached breaking out of the loop\n";}
last();
if($DBX){print STDERR "Transfer limit of $file_limit reached breaking out of the loop\n";}
last();
}
}
else
+23 -2
View File
@@ -32,6 +32,7 @@
# 91123-0005 - First Build
# 110524-1052 - Added run-check concurrency check option
# 111128-1617 - Added Ftp persistence option
# 111130-1801 - Added Ftp validate option
#
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -57,6 +58,7 @@ $VARHTTP_path = 'http://10.0.0.4';
$file_limit = 1000;
$list_limit = 1000;
$FTPpersistent=0;
$FTPvalidate=0;
### begin parsing run-time options ###
if (length($ARGV[0])>1)
@@ -85,6 +87,7 @@ if (length($ARGV[0])>1)
print " [--ftp-pass=XXX] = FTP server password\n";
print " [--ftp-dir=XXX] = FTP server directory\n";
print " [--ftp-persistent] = Does not log out between every file transmission\n";
print " [--ftp-validate] = Checks for a file size on the file after transmission\n";
print "\n";
exit;
}
@@ -171,6 +174,12 @@ if (length($ARGV[0])>1)
if ($DB > 0)
{print "\n----- FTP PERSISTENT: $FTPpersistent -----\n\n";}
}
if ($args =~ /--ftp-validate/i)
{
$FTPvalidate=1;
if ($DB > 0)
{print "\n----- FTP VALIDATE: $FTPvalidate -----\n\n";}
}
}
}
else
@@ -300,9 +309,10 @@ foreach(@FILES)
$FILEsize2[$i] = (-s "$dir2/$FILES[$i]");
if ($DBX) {print "$dir2/$FILES[$i] $FILEsize2[$i]\n\n";}
if ($FILEsize1[$i] ne $FILEsize2[$i]) {
if ($FILEsize1[$i] ne $FILEsize2[$i])
{
if ($DBX) {print "not transfering $dir2/$FILES[$i]. File size mismatch $FILEsize2[$i] != $FILEsize1[$i]\n\n";}
}
}
if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
@@ -374,6 +384,17 @@ foreach(@FILES)
}
$ftp->binary();
$ftp->put("$dir2/$ALLfile", "$ALLfile");
if ($FTPvalidate > 0)
{
$FTPfilesize = $ftp->size("$ALLfile");
if($DBX){print STDERR "FTP FILESIZE: $FTPfilesize/$FILEsize1[$i] | $ALLfile\n";}
if ( ($FILEsize1[$i] > 100) && ($FTPfilesize < 100) )
{
print "ERROR! File did not transfer, exiting: $FTPfilesize/$FILEsize1[$i] | $ALLfile\n";
exit;
}
}
if ($FTPpersistent < 1)
{
$ftp->quit;