# Virus update script

**URL:** <https://community.unix.com/t/virus-update-script/263186>\
**Category:** Shell Programming and Scripting\
**Created:** [April 5, 2010, 2:57pm UTC](https://community.unix.com/t/virus-update-script/263186 "2010-04-05T14:57:18Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![mk07md](https://community.unix.com/letter_avatar/mk07md/32/6_449c533f586939b6e5f246632a46421f.png) [@mk07md](https://community.unix.com/u/mk07md)\
**Post date:** [April 5, 2010, 2:57pm UTC](https://community.unix.com/t/virus-update-script/263186/1 "2010-04-05T14:57:18Z")

</div>

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.

```nohighlight
"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

```nohighlight
#!/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");

```

---

<div class="post-metadata">

**Author:** ![soleil4716](https://community.unix.com/letter_avatar/soleil4716/32/6_449c533f586939b6e5f246632a46421f.png) [@soleil4716](https://community.unix.com/u/soleil4716)\
**Post date:** [April 5, 2010, 3:47pm UTC](https://community.unix.com/t/virus-update-script/263186/2 "2010-04-05T15:47:21Z")

</div>

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

```nohighlight

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

```

---

<div class="post-metadata">

**Author:** ![mk07md](https://community.unix.com/letter_avatar/mk07md/32/6_449c533f586939b6e5f246632a46421f.png) [@mk07md](https://community.unix.com/u/mk07md)\
**Post date:** [April 5, 2010, 4:25pm UTC](https://community.unix.com/t/virus-update-script/263186/3 "2010-04-05T16:25:10Z")

</div>

Thanks Soleil4716

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

---

<div class="post-metadata">

**Author:** ![soleil4716](https://community.unix.com/letter_avatar/soleil4716/32/6_449c533f586939b6e5f246632a46421f.png) [@soleil4716](https://community.unix.com/u/soleil4716)\
**Post date:** [April 5, 2010, 4:45pm UTC](https://community.unix.com/t/virus-update-script/263186/4 "2010-04-05T16:45:11Z")

</div>

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

```nohighlight
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

---

<div class="post-metadata">

**Author:** ![mk07md](https://community.unix.com/letter_avatar/mk07md/32/6_449c533f586939b6e5f246632a46421f.png) [@mk07md](https://community.unix.com/u/mk07md)\
**Post date:** [April 5, 2010, 4:50pm UTC](https://community.unix.com/t/virus-update-script/263186/5 "2010-04-05T16:50:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![soleil4716](https://community.unix.com/letter_avatar/soleil4716/32/6_449c533f586939b6e5f246632a46421f.png) [@soleil4716](https://community.unix.com/u/soleil4716)\
**Post date:** [April 5, 2010, 4:52pm UTC](https://community.unix.com/t/virus-update-script/263186/6 "2010-04-05T16:52:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mk07md](https://community.unix.com/letter_avatar/mk07md/32/6_449c533f586939b6e5f246632a46421f.png) [@mk07md](https://community.unix.com/u/mk07md)\
**Post date:** [April 5, 2010, 4:57pm UTC](https://community.unix.com/t/virus-update-script/263186/7 "2010-04-05T16:57:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![soleil4716](https://community.unix.com/letter_avatar/soleil4716/32/6_449c533f586939b6e5f246632a46421f.png) [@soleil4716](https://community.unix.com/u/soleil4716)\
**Post date:** [April 5, 2010, 5:03pm UTC](https://community.unix.com/t/virus-update-script/263186/8 "2010-04-05T17:03:29Z")

</div>

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 🙂

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

---

<div class="post-metadata">

**Author:** ![mk07md](https://community.unix.com/letter_avatar/mk07md/32/6_449c533f586939b6e5f246632a46421f.png) [@mk07md](https://community.unix.com/u/mk07md)\
**Post date:** [April 5, 2010, 7:14pm UTC](https://community.unix.com/t/virus-update-script/263186/9 "2010-04-05T19:14:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![soleil4716](https://community.unix.com/letter_avatar/soleil4716/32/6_449c533f586939b6e5f246632a46421f.png) [@soleil4716](https://community.unix.com/u/soleil4716)\
**Post date:** [April 5, 2010, 9:13pm UTC](https://community.unix.com/t/virus-update-script/263186/10 "2010-04-05T21:13:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mk07md](https://community.unix.com/letter_avatar/mk07md/32/6_449c533f586939b6e5f246632a46421f.png) [@mk07md](https://community.unix.com/u/mk07md)\
**Post date:** [April 6, 2010, 9:12am UTC](https://community.unix.com/t/virus-update-script/263186/11 "2010-04-06T09:12:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![soleil4716](https://community.unix.com/letter_avatar/soleil4716/32/6_449c533f586939b6e5f246632a46421f.png) [@soleil4716](https://community.unix.com/u/soleil4716)\
**Post date:** [April 6, 2010, 10:46am UTC](https://community.unix.com/t/virus-update-script/263186/12 "2010-04-06T10:46:59Z")

</div>

You have these two lines in your Perl code:

```nohighlight
$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:

```nohighlight
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.

---

<div class="post-metadata">

**Author:** ![mk07md](https://community.unix.com/letter_avatar/mk07md/32/6_449c533f586939b6e5f246632a46421f.png) [@mk07md](https://community.unix.com/u/mk07md)\
**Post date:** [April 6, 2010, 11:21am UTC](https://community.unix.com/t/virus-update-script/263186/13 "2010-04-06T11:21:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![soleil4716](https://community.unix.com/letter_avatar/soleil4716/32/6_449c533f586939b6e5f246632a46421f.png) [@soleil4716](https://community.unix.com/u/soleil4716)\
**Post date:** [April 6, 2010, 11:27am UTC](https://community.unix.com/t/virus-update-script/263186/14 "2010-04-06T11:27:29Z")

</div>

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

You can type this line in your browser:

```nohighlight
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.

---

<div class="post-metadata">

**Author:** ![mk07md](https://community.unix.com/letter_avatar/mk07md/32/6_449c533f586939b6e5f246632a46421f.png) [@mk07md](https://community.unix.com/u/mk07md)\
**Post date:** [April 6, 2010, 11:44am UTC](https://community.unix.com/t/virus-update-script/263186/15 "2010-04-06T11:44:37Z")

</div>

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!
