From 83ca0686aa82ec03c71c66874c6e08ab6cc5edd1 Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 30 Nov 2011 23:07:03 +0000 Subject: [PATCH] Added ftp validate option flag to crontab scripts git-svn-id: svn://192.168.202.10@1758 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl | 29 +++++++++++++++++++--- agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl | 25 +++++++++++++++++-- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl b/agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl index 93137628..0ffdfe5b 100644 --- a/agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl +++ b/agc_2-X/trunk/bin/AST_CRON_audio_3_ftp.pl @@ -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 diff --git a/agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl b/agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl index 76518f07..d95296a3 100644 --- a/agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl +++ b/agc_2-X/trunk/bin/AST_CRON_audio_4_ftp2.pl @@ -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;