Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

AntiVirus Signature Updater

by linebacker (Scribe)
on Jul 09, 2002 at 22:57 UTC ( #180647=snippet: print w/replies, xml ) Need Help??
Description: Big time thanks to rincew, grinder,jeffa,jwest,mt2k, hofmator,kvale,atoplc,fruiture, (if I forgot you and you helped me, I don't mean it as an insult. Just lost track). As a novice, while attempting to write this code, I was urged by many colleagues to use a different language (Java or Korn Shell). But I stuck with Perl and thanks to you all, now have a working program that does exactly what I hoped for!

If it wasn't for this site, I would not continue to work so hard at continuing my Perl education. I thank you for that.

I manage several (6) AV Servers (Norton AV Corporate Edition). These servers push AV Defs and schedule scans on the 897 managed clients.

We only use a 'trusted' source for AV Sig updates. While this trusted source provides a weekly 'liveupdate', Symantec releases new 'all inclusive' updates almost daily and the trusted source posts those almost immediately but holds on to the 'liveupdates' for about a week or so.

Many of the subscribers of the systems complained that 'MY' updates (the liveupdates) were always behind. So...I set about automating the all inclusive updates.

From a *NIX machine (Solaris or Linux) I update from the trusted site, twice daily. I then have an AT script on the AV Servers that ftp's, executes and distributes the avdefs.exe file once per day.

At least, that is my concept. This of course has to go into my production lab for a week, then I can roll it out for real

Here is my code. Thank you all very much for helping me to accomplish what probably sounds like a very trivial task, but for me is a major milestone.

#!/usr/bin/perl -w

use strict;
use Net::FTP;
use Mail::Mailer;

my $host = '';
my $user = 'anonymous';
my $pass = '';
my $remote_dir = '/pub/antivirus/NAV/signatures';
my $destination_dir = 'current-sig';
my $type = 'sendmail';
my $mailprog = Mail::Mailer->new($type);

my @lupd = ();
  if(-e "./lastupdate.txt") {
      or die "Error while opening lastupdate.txt ($!)";
    chomp( @lupd = <LASTUPDATE> );
      or die "Error while closing lastupdate.txt ($!)";

my %haveit;
  @haveit{ @lupd } = (1) x @lupd;

my $ftp = Net::FTP->new($host, Debug => 1);
      or die "Could not connect to ftp server ($!)";

my @listing = grep /x86\.exe$/i, $ftp->ls($remote_dir);
my @newupdate;

    for my $file (@listing) {
      next if $haveit{$file};
      if ($ftp->get($file, "$destination_dir/avdefs.exe")) {
        push @newupdate, $file;  


    or die "Couldn't open lastupdate.txt for appending ($!)";
  print NEWUPDATE map "$_\n", @newupdate;
    or die "Closing lastupdate.txt failed ($!)";

sub mailer {
my $file = shift;
my %headers = (
    'To' => '',
    'From' => '',
    'Subject' => 'New AntiVirus Signatures brought down'
    print $mailprog "The Latest AntiVirus signature is $file.\n";
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://180647]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2020-02-26 14:28 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (117 votes). Check out past polls.