This is a continuation of the same program I have been struggling with. I think it is about 95% there, but the last part still eludes me.

The goal is to update AV signatures if you have not 'seen' them before. I use a flat file containing update signature file names. I want to iterate through that file and compare it to the files found on the ftp server. If I have never seen the file (ending in x86.exe) then 'get' it.

I can't seem to get the arrays to compare with each other. Pointers are appreciated. Thanks to all those who already helped, I will pay it forward.

1 #!/usr/bin/perl -w 2 #use strict; 3 use Net::FTP; 4 my $host = 'www.ftp.com'; 5 my $user = 'anonymous'; 6 my $pass = 'updatepuller@ftp.com'; 7 my $remote_dir = '/pub/antivirus/NAV/signatures'; 8 my $destination_dir= "current-sig"; 9 $ftp = Net::FTP->new($host, Debug => 1); 10 $ftp->login($user,$pass); 11 my @listing = $ftp->ls("$remote_dir"); 12 $lflag = 0; 13 if(-e "./lastupdate.txt") { 14 open(LASTUPDATE,"./lastupdate.txt"); 15 @lupd = (<LASTUPDATE>); 16 close(LASTUPDATE); 17 $lflag = 1; 18 } else { 19 $lupd = ""; 20 } 21 foreach $line (@listing) { 22 chomp($line); 23 $lline = lc($line); 24 if ($lline =~ "x86.exe") { 25 foreach $haveit (@lupd) { 26 chomp($haveit); 27 if (($lflag == 0) || ($haveit ne $line)) { 28 $ftp->type("I"); 29 $ftp->get("$line"); 30 } 31 } 32 $newupdate .= "$line\n"; 33 } 34 } 35 $ftp->quit; 36 #@lupd = split(/\n/,$newupdate); 37 @nupd = ($newupdate); 38 open(NEWUPDATE,">>./lastupdate.txt"); 39 print NEWUPDATE @nupd; 40 close(NEWUPDATE);
Contents of lastupdate.txt after a run
/pub/antivirus/NAV/signatures/0708x86.exe/pub/antivirus/NAV/signatures/0703x86.exe

In reply to Anti-Virus Signature Updates by linebacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.