Re: [SLE] Setting a script to automatically download a file from nai.com ftp site?
From: Vilmar Alves Toledo Junior (junior_at_grupolates.com)
Date: 10/07/03
- Previous message: Damon Register: "Re: [SLE] Setting a script to automatically download a file from nai.com ftp site?"
- In reply to: Damian Buckley: "[SLE] Setting a script to automatically download a file from nai.com ftp site?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 07 Oct 2003 11:16:08 -0300 To: damian.it@fsb.org.uk
Sorry for big message, but this script works very fine.
You will need to put it in a script file and run it from cron.
Best Regards,
Vilmar Alves Toledo Junior
CTO - Grupo Lates
www.grupolates.com
---------------------------------------------CUTHERE-------------------------------------------
#!/bin/bash
# dat_update
# Original por Jorge Becerra (jorge AT sodatec org)
#
# Recebido em versão alterada, e alterado mais um pouco por:
# Augusto Campos (brain AT br-linux org) 07/2003
#
# Comentário do autor original:
# Feel free to use the script and distribute
# if you found any mistake, please email the author
#
# A versão atual funciona para mim, mas se alguém acrescentar
# características, ou limpar o código, favor me mandar uma cópia.
#
# proxy - descomente para configurar, se você precisar
#http_proxy="http://proxy.foo.br:3128/"
#ftp_proxy="http://proxy.foo.br:3128/"
# Where to get the nai update from
FTPDIR="ftp://ftp.nai.com/pub/datfiles/english/"
MAILTO="root"
# Location of uvscan files
UVSCANDIR="/usr/local/uvscan"
UVSCAN="$UVSCANDIR/uvscan"
# Location of files (check on your distribution)
LYNX="/usr/bin/lynx"
GREP="/bin/grep"
CUT="/usr/bin/cut"
WGET="/usr/bin/wget"
CP="/bin/cp"
RM="/bin/rm"
ECHO="/bin/echo"
MKDIR="/bin/mkdir"
CAT="/bin/cat"
TAR="/bin/tar"
MAIL="/bin/mail"
#
# You don't need to change from here
# At least if you don' know exactly what means :-)
#
if [ ! -x $UVSCAN ] ; then
$ECHO "uvscan not installed on: $UVSCAN"
exit
fi
if [ ! -x $LYNX ] ; then
$ECHO "lynx not installed on $LYNX "
exit
fi
cd $UVSCANDIR
if [ ! -d tmp ]; then
$MKDIR tmp
fi
cd tmp
# Get the page from nai
echo "Retrieving update list"
$LYNX -dump "$FTPDIR" > nai.ls
echo "Done"
# Extract filename of last version
$CAT nai.ls | $GREP 'ftp://ftp.nai.com' nai.ls | $GREP .tar | $CUT -c 7-
| head -1 >nai.fn
# Get current version
VERSION_CURRENT=`cut -d - -f 2 nai.fn | cut -d . -f 1`
if [ -z "$VERSION_CURRENT" ] ; then
$ECHO "cant get uvscan current version"
exit
fi
# Get version installed
VERSION_USED=`$UVSCAN --version | $GREP "Virus data file" | $CUT -d" "
-f4 | $CUT -c2-`
$ECHO "Version - current : $VERSION_CURRENT"
$ECHO "Version - used : $VERSION_USED"
if [ -z "$VERSION_USED" ] ; then
$ECHO "could not get version from $UVSCAN"
exit
fi
if [ "$VERSION_USED" -ge "$VERSION_CURRENT" ] ; then
$ECHO "Viruscan is up to date"
exit
fi
$ECHO "Viruscan needs to be updated"
DATNAME="dat-${VERSION_CURRENT}.tar"
echo "downloading $FTPDIR$DATNAME - please wait"
$WGET -c -o wupdate.log $FTPDIR$DATNAME
if [ $? -eq 0 ]; then
echo "downloaded ok"
if [ ! -d extract ] ; then
$MKDIR extract
fi
$RM -f extract/*
$TAR --extract --directory extract < $DATNAME
if [ ! $? -eq 0 ]; then
$ECHO "ERROR extracting"
exit
fi
$RM -f extract/*.exe
$CP -f extract/* $UVSCANDIR/
$RM -f extract/*
$MAIL -s "uvscan dat updated to version: ${VERSION_CURRENT}" $MAILTO
< wupdate.log
else
$ECHO "error downloading"
fi
$RM -f wupdate.log
---------------------------------------------CUTHERE-------------------------------------------
Damian Buckley wrote:
> Hello,
> I want to be able to download my anti-virus weekly update files in
> the middle of the night through the use of a script and ftping??? I
> want to connect to ftp.nai.com and download the sdat weekly anti-virus
> update. Is this possible and if so can anybody point me in the right
> direction.
>
> Thanx in advance
>
> Damian Buckley
>
>
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
- Previous message: Damon Register: "Re: [SLE] Setting a script to automatically download a file from nai.com ftp site?"
- In reply to: Damian Buckley: "[SLE] Setting a script to automatically download a file from nai.com ftp site?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|