Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NAI ftp script for updates 1

Status
Not open for further replies.

ChrisHirst

IS-IT--Management
Nov 23, 2001
8,049
0
0
GB
Batch file and ftp script to download dat updates from NAI
change the drives and paths to suit your system. I use this to download to a local IIS ftp site.
I also copy sdat????.exe to dat.exe to give a constant file name for any scheduled operations (updates to groupshield etc)
To use this copy and paste the text below into notepad, change the paths as required and put your e-mail address into the ftp script. save as the file names shown. You can then run the batch file manually or schedule it and have your client machines point to the download location using ftp or as a UNC name.
If you use this on dial up you will need to add rasdial commands to the batch file to connect and disconnect automatically.


Chris.

save this as ftp.bat
rem drive
l:
rem folder
rem this will be the download location
rem and the shared folder on your ftp site
cd l:\updates\antivirus\current

rem delete previous update files
del *.ini
del sdat*.*
del *.txt
del *.upd
del *.zip

rem Change path below to suit your script path
ftp -i -s:L:\Updates\AntiVirus\Update\Scripts\nai.ftp > ftp.log
rem echo ftp commands to a log file

rem Copy the superdat to a fixed file name
xcopy sdat*.exe dat.* /y

rem run superdat in silent mode
dat.exe /s
rem end of batch file

***********************************************************
save this as nai.ftp

open ftp.nai.com
anonymous
me@wherever.xxx
cd pub\antivirus\datfiles\4.x
type ascii
mget *.ini
mget *.txt
type binary
mget *.upd
mget dat*.zip
mget sdat*.*
bye

end of ftp file
***************************************************
 
Hi,

This FTP script is really a good option.I used it with windows task scheduler to schedule the download.I copy the contents of the download to a network share every night and I use EPO 2.5 to distribute the updates from the share to the clients.

However , i would like to have a mechanism to check for failed downloads within the script and copy the datfiles to the network share in production ONLY if the ftp process was successful and complete.

If anyone has suggestions, pls advise ASAP.Thanks in advance
 
This script will down load dats from the NAI ftp server, make sure they were pulled down, and then copy it to the inhouse FTP server. Hope this helps.

Make sure the bat file and the nai.txt are in the same directory. I kept mine in the c:\virus\command directory.

IMPORTANT!!! Run this as "virus.bat 1 2 3"

Virus.bat

:virus
If NOT %1 == 3 goto virus
goto end1
:virus
REM -------- Start DAT update --------------
cd c:\virus\command
ftp -s:nai.txt
REM ----------------------------------------
echo %1
SHIFT
REM -------------- Check if files downloaded ------------
cd c:\virus\dat
if exist dat*.zip goto upload
goto virus
REM ------------------------------------------------------
:upload
REM -------- Delete and copy files on ftp server ---------
net use v: \\your ftp server\your share
v:
del *.* /Q
c:
cd \virus\dat
copy *.* v: /y
del *.* /Q
REM -------------------------------------------------------
NET SEND %computername% "The DATs have been updated @ %time% on %date%
goto end
:end1
net send %computername% "The DATs did not download"
:end

-------------------------------------------------------------------------------------------------------------------
NAI.txt

open ftp.nai.com
anonymous
mrupgrade@mrmr.com
cd pub/antivirus/datfiles/4.x
lcd c:\virus\dat
prompt
hash
mget sdat*.exe
mget dat*.zip
mget up*.ini
quit


 
Hi, i made a script which checks the nai ftp site for updates and if there is a newer one it downloads it:
(i left the directories as i use em but you can change tio any you like)

batchfile: check.cmd
==========================================================
::mad:ECHO OFF

::FTP into the site using a script
%windir%\system32\ftp -s:d:\antivirus\scripts\login.sc ftp.nai.com

::Create variables to check
FOR /F "tokens=*" %%A IN ('TYPE d:\antivirus\datfiles\new\files ^| SORT') DO set new= %%A
FOR /F "tokens=*" %%B IN ('TYPE d:\antivirus\datfiles\old\files ^| SORT') DO set old= %%B

::Are the Files equal??
IF %new% == %old% GOTO FILESEQ
IF NOT %new% == %old% GOTO FILESNEQ
::Do Nothing
:FILESEQ
now datfiles are equal >> d:\antivirus\log\dat_download.log
GOTO END

::Create alert
:FILESNEQ
%windir%\system32\ftp -s:d:\antivirus\scripts\newfiles.sc ftp.nai.com
::Send an alert
now datfiles are newer download started >> d:\antivirus\log\dat_download.log

::The file is newer and copy to new so we don't get told about it till the next update
COPY d:\antivirus\datfiles\new\files d:\antivirus\datfiles\old\files > NUL
COPY d:\antivirus\dafiles\sd*.exe d:\antivirus\superdat > NUL
del d:\antivirus\superdat\update.ini
COPY d:\antivirus\datfiles\update.ini d:\antivirus\superdat > NUL
copy d:\antivirus\datfiles\update.ini d:\ftp\pub\antivirus\datfiles\4.x\ /Y > NUL
copy d:\antivirus\datfiles\delta.ini d:\ftp\pub\antivirus\datfiles\4.x\ /Y > NUL
copy d:\antivirus\datfiles\*.upd d:\ftp\pub\antivirus\datfiles\4.x\ /Y > NUL
copy d:\antivirus\datfiles\*.zip d:\ftp\pub\antivirus\datfiles\4.x\ /Y > NUL
copy d:\antivirus\datfiles\*.exe d:\ftp\pub\antivirus\datfiles\4.x\ /Y > NUL
GOTO END

:END
==========================================================
script file: login.sc
==========================================================
anonymous
user@domain.com
cd pub/antivirus/datfiles/4.x/
ls *.upd d:\antivirus\datfiles\new\files
bye
==========================================================
Script file: newfiles.sc
==========================================================
anonymous
user@domain.com
cd /pub/antivirus/datfiles/4.x
lcd d:\antivirus\datfiles
::Turn Prompting off - Needed for Microsoft FTP clients. UNIX should be turned off.
prompt
Mget *.upd
Mget *.zip
Mget *.exe
get update.ini
get delta.ini
bye
===========================================================


Hope this helps, it works for me and has a decent logging of
actions to use the "now" command u need to have installed the resourcekit


Regards, Craven
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top