Jump to content

Automated FTP


Recommended Posts

Every morning I download the newest McAfee DAT file and SuperDAT file to a local server for all users in my office. It used to be every week, but now new DAT files are made available every day. This is a good thing, but I'm getting tired of manually downloading these files every day.

So I wrote a little BAT file that initiates FTP connects, etc., but it doesn't work!

  1. It does not take userid, password, and commands from the BAT script.
  2. Even if it did (I'm sure there is a way), it does not accept wildcards in the name, such as get dat*

Any suggestions?

Link to comment
Share on other sites

I need a little bit more help with this. I wrote a little batch script that I added to the task scheduler to run every morning:

Z:
cd \Install\AntiVirus\DAT
del dat*
del update.ini
C:\PROGRA~1\wget\wgët ftp://ftp.mcafee.com/pub/datfiles/japanese/dat*
C:\PROGRA~1\wget\wgêt ftp://ftp.mcafee.com/pub/datfiles/japanese/update.ini
X:
cd \jpnnyan\Install\AntiVirus\Superdat-J
del sdat*
del update.ini
C:\PROGRA~1\wget\wgét ftp://ftp.mcafee.com/pub/datfiles/japanese/sdat*
C:\PROGRA~1\wget\wgèt ftp://ftp.mcafee.com/pub/datfiles/japanese/update.ini
exit

This works beautifully -- as long as the network is stable. This weekend it was not the case; so the script deleted the DAT files, but was unable to download a new one.

Question: is there a way to test the return code of "wgėt" so that I could restore the DAT files if the download fails?

Link to comment
Share on other sites

Tested, and ŵģęť returns 1 if the operation fails. My new script:

Z:
cd \Install\AntiVirus\DAT
del BACKUP\dat*
del BACKUP\update.ini
move dat* BACKUP
move update.ini BACKUP
C:\PROGRA~1\wget\wgėt ftp://ftp.mcafee.com/pub/datfiles/japanese/dat*
if errorlevel 1 copy /Y BACKUP\dat*
C:\PROGRA~1\wget\wgėt ftp://ftp.mcafee.com/pub/datfiles/japanese/update.ini
if errorlevel 1 copy /Y BACKUP\update.ini
X:
cd \jpnnyan\Install\AntiVirus\Superdat-J
del BACKUP\sdat*
del BACKUP\update.ini
move sdat* BACKUP
move update.ini BACKUP
C:\PROGRA~1\wget\wgėt ftp://ftp.mcafee.com/pub/datfiles/japanese/sdat*
if errorlevel 1 copy /Y BACKUP\sdat*
C:\PROGRA~1\wget\wgėt ftp://ftp.mcafee.com/pub/datfiles/japanese/update.ini
if errorlevel 1 copy /Y BACKUP\update.ini
exit

Thanks for the help! :)

Updated script to eliminate confirmation prompt from del *.*

Link to comment
Share on other sites

Here is the final script, now that it's completely tested and everything works as expected.

rem ------------------------------
rem Backup old, download new files
rem ------------------------------
X:
cd \jpnnyan\Install\AntiVirus\DAT
del /Q BACKUP\dat*
move dat* BACKUP
C:\PROGRA~1\wget\wget.exe ftp://ftp.mcafee.com/pub/datfiles/japanese/dat*
if errorlevel 1 copy /Y BACKUP\dat*
del BACKUP\update.ini
move update.ini BACKUP
C:\PROGRA~1\wget\wget.exe ftp://ftp.mcafee.com/pub/datfiles/japanese/update.ini
if errorlevel 1 copy /Y BACKUP\update.ini
rem
rem ------------------------------
rem Copy files to JPNNYAN location
rem ------------------------------
del /Q Z:\Install\AntiVirus\DAT\dat*
copy /Y dat* Z:\Install\AntiVirus\DAT
del Z:\Install\AntiVirus\DAT\update.ini
copy /Y update.ini Z:\Install\AntiVirus\DAT
rem
rem ------------------------------
rem Backup old, download new files
rem ------------------------------
X:
cd \jpnnyan\Install\AntiVirus\Superdat-J
del /Q BACKUP\sdat*
move sdat* BACKUP
C:\PROGRA~1\wget\wget.exe ftp://ftp.mcafee.com/pub/datfiles/japanese/sdat*
if errorlevel 1 copy /Y BACKUP\sdat*
del BACKUP\update.ini
move update.ini BACKUP
C:\PROGRA~1\wget\wget.exe ftp://ftp.mcafee.com/pub/datfiles/japanese/update.ini
if errorlevel 1 copy /Y BACKUP\update.ini
exit /B 0

Link to comment
Share on other sites

  • 3 weeks later...

This is as good as any place to announce that "wget" 1.10 has been released.

See ftp://ftp.gnu.org/gnu/wget/; Windows executables are available from http://xoomer.virgilio.it/hherold/.

Here is a list of changes for "wget" 1.10:

http://xoomer.virgilio.it/hherold/News

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy