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

  • Next message: Stan Glasoe: "Re: [SLE] GIMP-. No "Print" option in File menu (GIMP1.3.19, SuSE 8.2) [repost, last time] + apologies"
    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
    

  • Next message: Stan Glasoe: "Re: [SLE] GIMP-. No "Print" option in File menu (GIMP1.3.19, SuSE 8.2) [repost, last time] + apologies"

    Relevant Pages

    • Re: Command Script variable value lost during execution
      ... the command prompt after the script exit? ... I also added all those ECHO to follow the logic and as you can see in the ... a system but the value of the variable is lost during execution and it get back it's value when exiting the script like if I was using SETLOCAL but I don't use it... ... :: Check the version of RoboCopy from the Date ...
      (microsoft.public.windows.server.scripting)
    • ToDo list utility - suggestions/optimizations/refinements wanted
      ... For the past couple of days, I've been working on this todo list script and I'm really happy with the way it works, but wanted to post it here before I go any futher, in case anybody had suggestions for optimizations or style errors. ... echo "File written successfully." ...
      (comp.unix.shell)
    • Re: Bash script Slack >> Deb-Etch
      ... echo>> ~/.signature ... -wF chokes cut, and the switch isn't ... Somehow in the script ...
      (comp.os.linux.misc)
    • Re: Script to compare two directory structures
      ... echo $1: `sum $1` ... # Script to compare two directory structures to see if they are the ...
      (comp.sources.d)
    • Re: [Full-disclosure] reduction of brute force login attempts via SSHthrough iptables --
      ... Anyhow its no problem at all to modify, so if you dont like it, just dont use it. ... on a lame script like this as long as it WORKS and is not insecure. ... echo "~ sorting out ip by ip" ... # echo "not enough failed logins, probably no attack from: ...
      (Full-Disclosure)