Board logo

标题: [特效代码] 批处理如何下载symantec FTP上面最新日期的XDB文件? [打印本页]

作者: wolf1981    时间: 2010-11-28 16:52     标题: 批处理如何下载symantec FTP上面最新日期的XDB文件?

批处理如何下载symantec FTP上面最新日期的XDB文件?

我写了一点可以使用,但只能是全部下载,我想下其中一个最新的文件,例如只下载最新日期的vd32f602.xdb
symantec FTP 的XDB目录下只有4个文件,symantec FTP上显示的年份不对,时间格式应该是YY:mmD,怎样在下面已可以下载的代码中加入获取最新日期XDB文件后再开始下载?高手帮下忙。。。谢谢

-rw-rw-r--   1     1994     1994 110400150 Nov 24 17:05 vd32f004.xdb
-rw-rw-r--   1     1994     1994 112513153 Nov 25 14:20 vd32f202.xdb
-rw-rw-r--   1     1994     1994 112179419 Nov 26 15:03 vd32f403.xdb
-rw-rw-r--   1     1994     1994 113688475 Nov 27 14:18 vd32f602.xdb
--------------------------------------------------------
可以下载的代码
  1. @echo off
  2. echo open ftp.symantec.com>c:\ftp.txt
  3. echo anonymous>>c:\ftp.txt
  4. echo anonymous>>c:\ftp.txt
  5. echo cd public/english_us_canada/antivirus_definitions/norton_antivirus/xdb>>c:\ftp.txt
  6. echo lcd D:\NAV Update file>>c:\ftp.txt
  7. echo bin>>c:\ftp.txt
  8. echo mget *.xdb>>c:\ftp.txt
  9. echo quit>>c:\ftp.txt
  10. Start ftp -v -i -s:"c:\ftp.txt"
复制代码

-------------------------------------------------------

------------------------------------------------------
ftp> open
To ftp.symantec.com
Connected to 25280.ftp.download.akadns.net.
220 spftp/1.0.0000 Server [202.47.28.215]
User (25280.ftp.download.akadns.netnone)): anonymous
331 Password required for USER.
Password:
230-
230- ---------------------------------------------------------------------------
230- WARNING:  This is a restricted access system.  If you do not have explicit
230-           permission to access this system, please disconnect immediately!
230 ----------------------------------------------------------------------------
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /.
AVDEFS
IPSDEFS
comwrap
misc
public
usr
226 Transfer Complete
ftp: 45 bytes received in 0.09Seconds 0.48Kbytes/sec.
ftp> cd public/english_us_canada/antivirus_definitions/norton_antivirus/xdb
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /public/english_us_canada/antivirus_definitions/norton_antivirus/xdb.
vd32f004.xdb
vd32f202.xdb
vd32f403.xdb
vd32f602.xdb
226 Transfer Complete
ftp> dir
-rw-rw-r--   1     1994     1994 110400150 Nov 24 17:05 vd32f004.xdb
-rw-rw-r--   1     1994     1994 112513153 Nov 25 14:20 vd32f202.xdb
-rw-rw-r--   1     1994     1994 112179419 Nov 26 15:03 vd32f403.xdb
-rw-rw-r--   1     1994     1994 113688475 Nov 27 14:18 vd32f602.xdb

[ 本帖最后由 wolf1981 于 2010-11-28 22:15 编辑 ]
作者: wolf1981    时间: 2010-11-28 17:43

在百度找到了一个批处理自动下载前一天的文件,应该怎么改?

或者换一种思路?我把那4个XDB文件都下载E:\Temp目录里,每次自动下载前对比一下E:\Temp目录里的文件和FTP上的有什么不同,然后只下载不同的?帮手写写?谢谢
  1. @echo off
  2. echo WScript.Echo DateDiff("d","2010-11-28",Date)>_d_tmp.vbs
  3. for /f %%i in ('cscript /Nologo _d_tmp.vbs') do set "days=%%i"
  4. if "%days:~0,-1%"=="" set days=00%days%
  5. if "%days:~0,-2%"=="" set days=0%days%
  6. del _d_tmp.vbs
  7. echo open ftp.symantec.com>c:\ftp.txt
  8. echo anonymous>>c:\ftp.txt
  9. echo anonymous>>c:\ftp.txt
  10. echo cd public/english_us_canada/antivirus_definitions/norton_antivirus/xdb>>c:\ftp.txt
  11. echo lcd D:\NAV Update file>>c:\ftp.txt
  12. echo bin>>c:\ftp.txt
  13. echo mget *.xdb>>c:\ftp.txt
  14. echo quit>>c:\ftp.txt
  15. Start ftp -v -i -s:"c:\ftp.txt"
复制代码


[ 本帖最后由 wolf1981 于 2010-11-28 22:15 编辑 ]
作者: andyrave    时间: 2010-11-28 19:39

换WGET  

扩展命令丰富

可以满足你的要求
作者: wolf1981    时间: 2010-11-28 19:42

找到一个类似的VBS可以下载的,但原始的代码是下载EXE文件的,下载自动执行更新的,我要的xdb文件不用执行,可下载最新的XDB文件即可,高手帮手改改


  1. dtmYesterday = DateAdd("d",-1,Date)
  2. strYear      = DatePart("yyyy",dtmYesterday)
  3. If DatePart("m",dtmYesterday) < 10 Then
  4.         strMonth = 0 & DatePart("m",dtmYesterday)
  5. Else
  6.         strMonth = DatePart("m",dtmYesterday)
  7. End If
  8. If DatePart("d",dtmYesterday) < 10 Then
  9.         strDay = 0 & DatePart("d",dtmYesterday)
  10. Else
  11.         strDay = DatePart("d",dtmYesterday)
  12. End If
  13. strYest = strYear & strMonth & strDay
  14. Set WshShell = CreateObject("WScript.Shell")
  15. Set fso = CreateObject("Scripting.FileSystemObject")
  16. TemporaryFolder=fso.GetSpecialFolder(2)
  17. Set tso = fso.OpenTextFile(TemporaryFolder & "\ftp.txt", 8,true,0)
  18. tso.writeline "binary"
  19. tso.writeline "mget /public/english_us_canada/antivirus_definitions/norton_antivirus/xdb/" & strYest & "*.xdb"
  20. tso.writeline "bye"
  21. tso.close
  22. runstr="CMD /K cd /d " & TemporaryFolder & _
  23.         "&ftp -A -i -s:ftp.txt ftp.symantec.com"
  24. WshShell.Run(runstr)
  25. runupdate="CMD /K CD /d "& TemporaryFolder & "\" & strYest & "*-x86.exe"        运行更新?就不用了
  26. WshShell.Run(runupdate)
  27. Set f = fso.GetFolder(TemporaryFolder)
  28. Set fc = f.Files
  29. For Each f1 in fc
  30.         if instr(f1.name,strYest) and instr(f1.name,"-x86.exe") Then
  31.                 Set oExec = WshShell.Exec(TemporaryFolder & "\" & f1.name & " /q")
  32.                 Do While oExec.Status = 0
  33.                              WScript.Sleep 10
  34.                 Loop
  35.                 fso.DeleteFile(TemporaryFolder & "\" & f1.name)
  36.         end if
  37. Next
  38. fso.DeleteFile(TemporaryFolder & "\ftp.txt")
  39. Set WshShell = Nothing
复制代码


[ 本帖最后由 wolf1981 于 2010-11-28 22:16 编辑 ]




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2