Here's an update on my NAV pattern downloader. Recently I put out a cry for help here but nobody replied. [Frown]

I deleted the previous two posts as they no longer apply.

Basically, to make a long story short, Symantec has once again changed how they post their latest pattern file.  Used to be, you could just download their vpcur.lst file and just rip the current filename from it.  Not so any more.  Vpcur.lst now often lags behind the most current.

What I do now is an ftp 'ls' command and redirect the output to a file, parse the file, and ascertain the newest.

code:
 Break on
;========================================
; NAV pattern file version checker, downloader, and updater
; by les_ligetfalvy
; updated August 9th, 2002
;========================================
; First we determine current pattern file on NAV Parent server
;
$Error =""
$WorkDir ="C:\NAVKiX"
$VPHome ="C:\Program Files\NAV"
$HKLMSILVP6CV = "HKEY_LOCAL_MACHINE\SOFTWARE\Intel\LANDesk\VirusProtect6\CurrentVersion"
$Newest = ReadValue($HKLMSILVP6CV,"CurrentPatternName")
$RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","ExistingPattern",$Newest)
If Exist($WorkDir + "\" + $Newest) Del $WorkDir + "\" + $Newest EndIf

;========================================
; Then we FTP to get vpcur.txt
;
If Exist($WorkDir + "\vpcur.txt") Del $WorkDir + "\vpcur.txt" EndIf
$FTPScript = $WorkDir + "\CEGetCurrent.txt"
$ShellCMD ="ftp -s:" + $FTPScript
If Exist($FTPScript) Del '$FTPScript' Endif
If RedirectOutput($FTPScript) = 0
"open ftp.symantec.com" ?
"anonymous" ?
"myname@@mycompany.com" ?
"cd public/english_us_canada/antivirus_definitions/norton_antivirus/vdb" ?
"lcd " + $WorkDir ?
"bin" ?
"hash" ?
"prompt" ?
"ls *.vdb " + $WorkDir + "\vpcur.txt" ?
"quit" ?
$rc = RedirectOutput("")
Else
$Error ="Failed to create " + $FTPScript
GoTo Done
Endif
Shell '$ShellCMD'
;========================================
; Now we check vpcur.txt
;
$Index = 0
Dim $FNArray[10]
$FNewest = 0
If (Open(1,$WorkDir + "\vpcur.txt") = 0) And (GetFileSize($WorkDir + "\vpcur.txt") <> 0)
$Line = ReadLine(1)
While $Line <> "" And @Error = 0
If Val("&" + Substr($Line,3,6)) <> 0
$FNArray[$Index] = Val("&" + Substr($Line,3,6))
$Index = $Index + 1
EndIf
$Line = ReadLine(1)
Loop
For $X = 0 To $Index Step 1
If $FNArray[$X] > $FNewest
$FNewest = $FNArray[$X]
EndIf
Next
$vpcur = LCase("vd" + DectoHex($FNewest) + ".vdb")
If Val("&" + SubStr($vpcur,3,6)) <= Val("&" + SubStr($Newest,3,6))
$RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","LastChecked",@Date + " - " + @Time)
GoTo Done
Else
;========================================
; Then we FTP to get latest pattern, same as for vpcur.txt only different
;
If Exist($WorkDir + "\*.vdb") Del $WorkDir + "\*.vdb" EndIf
$FTPScript = $WorkDir + "\CEGetPattern.txt"
$ShellCMD ="ftp -s:" + $FTPScript
If Exist($FTPScript) Del '$FTPScript' Endif
If RedirectOutput($FTPScript) = 0
"open ftp.symantec.com" ?
"anonymous" ?
"myname@@mycompany.com" ?
"cd public/english_us_canada/antivirus_definitions/norton_antivirus/vdb" ?
"lcd " + $WorkDir ?
"bin" ?
"hash" ?
"prompt" ?
"get " + $vpcur ?
"quit" ?
$rc = RedirectOutput("")
Else
$Error ="Failed to create " + $FTPScript
GoTo Done
Endif
Shell '$ShellCMD'
;========================================
; Now we see if $vpcur downloaded and if so, copy and cleanup
;
If GetFileSize($WorkDir + "\" + $vpcur) <> 0
$CopySource = $WorkDir + "\" + $vpcur
Copy $CopySource $VPHome
Else
$Error ="Download of $vpcur failed!"
GoTo Done
EndIf
;========================================
EndIf
Else
$Error = "Download of vpcur.txt failed!"
GoTo Done
EndIf
$RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","LastDownloaded",$vpcur)
$RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","LastUpdated",@Date + " - " + @Time)
$RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","LastChecked","")
$RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","ExistingPattern","")
:Done
$RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","Error",$Error)

Exit 1

{edit} Fixed a couple of bugs.
1. If FTP failed, need to check for a zero-byte file.
2. Needed to convert filename to LC as FTP is case sensitive.

[ 20. January 2003, 16:19: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.