Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-16 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found