Virus update script

Hello everyone, this is my first post in the forum. I have antivirus update script but for some reason it is not running for some time.
I am getting this message everytime i try to run the updates.

"1 at /usr/local/bin/update-uvscan.pl line 22.
Update file could not be downloaded!"

The script is below. Please help
thanks is advance!
Khan

#!/usr/bin/perl
# written by fox
# to update the virus scanner
# Now includes a rate limit of 2mbit/s (250kbyte/s)

# tmp dir to use (it creates and deletes it. parent directory should exist) no trailing slash
$tmpdir="/tmp/update-virus-scanner";

# ftp site and location of dat files. no trailing slash
$ftpsite="ftp://ftp.mcafee.com/pub/antivirus/datfiles/4.x";
#$ftpsite="http://download.nai.com/products/datfiles/4.x/nai";

# location of the av scanner. no trailing slash
$avscanner="/usr/local/uvscan";

system("rm -rf $tmpdir");
system("mkdir $tmpdir");
system("wget -t2 -T60 --limit-rate=250k --passive-ftp -q -P$tmpdir $ftpsite/update.ini");

open(FILE, "$tmp/dat-update") || die print "Update file could not be downloaded!\n";

$line=<FILE>;
while ($line) {
 if ($line =~ "DATVersion") {
  ($junk, $datversion) = split('=', $line);
 }
$line=<FILE>;
}
close(FILE);
$datversion=~s/\cM\n//g;
chomp($datversion);
#print $datversion, "\n";
system("$avscanner/uvscan --version >$tmpdir/ourversion");
open(FILE, "$tmpdir/ourversion") || die print "Could not find current dat version\n";
$line=<FILE>;
while ($line) {
 if ($line =~ "Virus data file") {
  ($junk, $bottom) = split(" v", $line);
  ($ourversion, $junk) = split(" c", $bottom);
 }
$line=<FILE>;
}
close(FILE);
chomp($ourversion);
#print $ourversion, "\n";
if ($datversion > $ourversion) {
 system("wget --passive-ftp -q -P$tmpdir $ftpsite/dat-$datversion.zip");
 system("unzip -qq $tmpdir/dat-$datversion.zip -d $tmpdir");
 system("mv $tmpdir/*.dat $avscanner/");
 system("chmod 644 $avscanner/*.dat");
}
system("rm -rf $tmpdir");

Most likely you need to use '$tmpdir' not '$tmp':


open(FILE, "$tmpdir/dat-update") || die print "Update file could not be downloaded!\n";

Thanks Soleil4716

Same thing:
I changed it from tmp to tmpdir but it getting the same error.

Most likely the following command is not getting the virus update file:

system("wget -t2 -T60 --limit-rate=250k --passive-ftp -q -P$tmpdir $ftpsite/update.ini");

Can you run the wget command by hand and check to see if you get the 'dat-update'
file under /tmp/update-virus-scanner

I am sorry but never used 'wget' before where will i ad this line in the file?

Well, this line is already in your script. I am just asking you to type this at the UNIX command prompt.

Please ignore my early message!

---------- Post updated at 04:57 PM ---------- Previous update was at 04:56 PM ----------

No it would not run on shell.

What output do you get when run from the shell? You need to do some copy-paste here buddy. Just telling 'it would not run' is not very helpful :slight_smile:

Please paste the command that you ran and the output you got.

This is the input and output as well:
=>wget --passive-ftp -q -P$tmpdir $ftpsite/dat-$datversion.zip

wget: missing URL
Usage: wget [OPTION]... ...

Try `wget --help' for more options.

You must be pretty new to UNIX/Perl. You cannot use Perl variables when you run the command in UNIX. You need to replace them with actual values.

Yes,
I am new to UNIX so how will i do this.
Thanks for your all help, really appreciate it.

You have these two lines in your Perl code:

$tmpdir="/tmp/update-virus-scanner";
$ftpsite="ftp://ftp.mcafee.com/pub/antivirus/datfiles/4.x";

So, you need to have the following in your command:

wget -t2 -T60 --limit-rate=250k --passive-ftp -q -P/tmp/update-virus-scanner \
ftp://ftp.mcafee.com/pub/antivirus/datfiles/4.x/update.ini

Note that I added a '\' at the end of the first line. It is line a continuation
character and means the rest of the command will come up in the following line.

wget: missing URL
Usage: wget [OPTION]... ...

Try `wget --help' for more options.
sh: line 1: ftp://ftp.mcafee.com/pub/antivirus/datfiles/4.x/update.ini: No such file or directory
Update file could not be downloaded!
1 at ./update-uvscan.pl line 23.

That pretty much sums it up. The URL that you are specifying, does not exist.

You can type this line in your browser:

ftp://ftp.mcafee.com/pub/antivirus/datfiles/4.x

and you'll see that there is no update.ini file listed there. Please work with your team/supervisor about this.

Your are right there is no update.ini. Thanks for your all help i have given this script to my boss and he will be taking care of this.
Thanks again!