Page 1 of 2 12>
Topic Options
#38708 - 2003-04-02 04:07 PM NAV Def files and Dates
DJC Offline
Fresh Scripter

Registered: 2003-04-02
Posts: 8
Loc: UK
I am trying to get my script to calculate the current date compared to the current NAV def date in c:\program files\common files\Symantec shared\virusdefs\definfo.dat 20030326.002
I need to get warning if its say 30 days since the date in the file.
I think i need to trim off the last 4 characters and then some how calculate the difference but i am having problems with this.
Can anyone help?
_________________________
Currently on : KiXtart 95 3.60

Top
#38709 - 2003-04-02 04:11 PM Re: NAV Def files and Dates
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Use SPLIT() to separate the pathnames, use SUBSTR to separate the date field and create a reald date, then use the DATEMATH() UDF to calculate date difference. Pseudo-code
code:
$a=split('c:\program files\common files\Symantec shared\virusdefs\definfo.dat 20030326.002','\')
$date=$a[ubound($a)]
$date=split($date,'.')[0]
$year=left($date,4)
$month=substr($date,5,2)
$day=right($date,2)
$date=$year+'/'+$month+'/'+$day
$datediff=datemath($date,@DATE)

_________________________
There are two types of vessels, submarines and targets.

Top
#38710 - 2003-04-02 04:23 PM Re: NAV Def files and Dates
DJC Offline
Fresh Scripter

Registered: 2003-04-02
Posts: 8
Loc: UK
Sorry i am using KiXtart 95 3.60 and am unable to change the version as its a corporate thing.
I cant use UDF's ... any ideas?
_________________________
Currently on : KiXtart 95 3.60

Top
#38711 - 2003-04-02 04:25 PM Re: NAV Def files and Dates
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yessir

use Richards subroutines written for 3.x doing the same ... wait I'll dig them up

Get yer date maths routines here.

[ 02. April 2003, 16:26: Message edited by: jpols ]
_________________________



Top
#38712 - 2003-04-02 04:26 PM Re: NAV Def files and Dates
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Rewrite the UDFs as subroutines. You will also need to re-engineer the SPLIT command.

Upgrading to kiXtart 4.2x is highly recommended, especially when supporting Windows 2000 and active Directory.

However, the basic program flow still applies. And the next time, please provide all necessary info as outlined in ABC's of KiXtart board etiquette and message to new forum users . This would save much time/grief in helping.
_________________________
There are two types of vessels, submarines and targets.

Top
#38713 - 2003-04-02 04:30 PM Re: NAV Def files and Dates
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Additionaly here is cj's vbsplit subroutine:

reply #3 in this topic
_________________________



Top
#38714 - 2003-04-03 02:41 PM Re: NAV Def files and Dates
DJC Offline
Fresh Scripter

Registered: 2003-04-02
Posts: 8
Loc: UK
I am quite new to the scripting lark and i have come up with the below after reading through the posts, All i need to do is test if the date in the file is older than 2 weeks.
The below does not appear to work but i believe its Close, Any ideas?

code:
$CurDefDate = ReadProfileString ("c:\program files\common files\symantec shared\virusdefs\definfo.dat", "DefDates", "CurDefs" )

; The above file contains :

; [DefDates]
;CurDefs=20030326.002
;LastDefs=20030319.002

code:
$FileYear = ltrim (SubStr($CurDefDate, 1, 4))
$FileMonth = ltrim (SubStr($CurDefDate, 5, 2))
$FileDay = ltrim (SubStr($CurDefDate, 7, 2))
$DefDates = "$FileYear$FileMonth$FileDay"

$FileDate = SubStr($DefDates,1,10)
?$FileDate

$NowYear = @YEAR
$NowMonth = @MONTHNO
$NowDate = @MDAYNO

If $FileYear <> $NowYear
$NowMonth = $NowMonth + (12 * ($NowYear - $FileYear))
EndIf

If $FileMonth <> $NowMonth
$NowDate = $NowDate + 30
EndIf
If ($NowDate - $FileDate) > 10
? "File older than 2 weeks"
Else
? "File newer than 2 weeks"
EndIf

_________________________
Currently on : KiXtart 95 3.60

Top
#38715 - 2003-04-03 05:09 PM Re: NAV Def files and Dates
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You'll need to convert your dates to values instead of strings, e.g.
code:
$FileYear = val(ltrim (SubStr($CurDefDate, 1, 4)))
$FileMonth = val(ltrim (SubStr($CurDefDate, 5, 2)))
$FileDay = val(ltrim (SubStr($CurDefDate, 7, 2)) )



[ 04. April 2003, 16:49: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#38716 - 2003-04-03 09:00 PM Re: NAV Def files and Dates
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Not sure I agree with your date logic for OLDER/NEWER files.

Here is another method of getting the date - Not very clean, but works. I'm sure Jens or Lonkero can GOLF it. [Razz]



$CurDefDate = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\SharedDefs","NAVCORP_70")
$CurDefDate=right($CurDefDate,12)
$CurDefDate=left($CurDefDate,8)
$FileYear = VAL(RTRIM (SubStr($CurDefDate14)))
$FileMonth = VAL(RTRIM (SubStr($CurDefDate52)))
$FileDay = VAL(RTRIM (SubStr($CurDefDate72)))
$DefDates =  "$FileYear$FileMonth$FileDay"
$FileDate = VAL(SubStr($DefDates,1,8))
     
$NowYear = @YEAR
$NowMonth = @MONTHNO
$NowDate = @MDAYNO
 
If $FileYear <$NowYear
  $NowMonth = $NowMonth + (12 * ($NowYear - $FileYear))
EndIf

If $FileMonth <$NowMonth
  $NowDate = $NowDate + 30
EndIf
If ($NowDate - $FileDate) > 10
  ? "File older than 2 weeks"
Else 
  ? "File newer than 2 weeks"
ENDIF
$FileDate


Top
#38717 - 2003-04-03 09:34 PM Re: NAV Def files and Dates
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
This all sounds convoluted. I have to wonder why you would not just use the Corporate Edition of NAV/SAV. The SSC will show any old pattern dates.

If you want a belt & suspenders, you could pull the current pattern version from the parent server and store it in an INI. Then pull the current pattern version from the client and simply compare to what's in the INI. If they don't match, check a counter in the INI. If the counter is zero, increment. If the counter is non-zero, take decisive action.

With a well configured NAV CE / SAV CE, the client should get the latest pattern within minutes of logon.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#38718 - 2003-04-03 09:40 PM Re: NAV Def files and Dates
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Les is correct for Management.

I'd only use a portion of this for REPORTING purposes. That way you could log systems that for one reason or another have problems updating. We use Corp version and it works great on about 98% of the systems, but for one reason or another we do have systems that don't update as there supposed to. Logging allows you to find these systems and take action when/if needed.

Top
#38719 - 2003-04-04 10:50 AM Re: NAV Def files and Dates
DJC Offline
Fresh Scripter

Registered: 2003-04-02
Posts: 8
Loc: UK
We have different subnets and they are different anti virus programs, All my NAV machines are on auto update from an ftp server via live update scheduled to run every so often.
This does not stop some of them from not being updated however.
All i need is just to check the date in the file against the current date and if over a cetain period to send a report (Via Blat).
None of the above have worked for me and i dont think it can be done with such an old version of Kix.
Thanks for all your help but i am at my wits end with this .. its been days now trying to work this out and i have searched everywhere. [Confused]
_________________________
Currently on : KiXtart 95 3.60

Top
#38720 - 2003-04-04 01:35 PM Re: NAV Def files and Dates
DJC Offline
Fresh Scripter

Registered: 2003-04-02
Posts: 8
Loc: UK
Typical!!!

A while after my last post i got it to work ..

It actually works as :

code:
$CurDefDate = ReadProfileString ("c:\program files\common files\symantec shared\virusdefs\definfo.dat", "DefDates", "CurDefs" )


$FileYear = val(ltrim (SubStr($CurDefDate, 1, 4)))
$FileMonth = Val(ltrim (SubStr($CurDefDate, 5, 2)))
$FileDay = Val(ltrim (SubStr($CurDefDate, 7, 2)) )


$NowYear = @YEAR
$NowMonth = @MONTHNO
$NowDay = @MDAYNO

If $FileYear <> $NowYear
$NowMonth = $NowMonth + (12 * ($NowYear - $FileYear))
EndIf

If $FileMonth <> $NowMonth
$NowDay = $NowDay + (30 * ($Nowmonth - $Filemonth))
EndIf

If ($Nowday - $Fileday) > 25

? "File older than 25 days"

Else

? "File newer than 25 days"

EndIf

This is the offending part that was missing :

code:
  If $FileMonth <> $NowMonth
$NowDay = $NowDay + (30 * ($Nowmonth - $Filemonth))

Once again Thanks for all your help ..
_________________________
Currently on : KiXtart 95 3.60

Top
#38721 - 2003-04-04 02:01 PM Re: NAV Def files and Dates
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
DJC,

I can't promise that this will work with 3.60 (as I don't have a copy and won't download) but despite my best knowledge the below WILL work (at any day as these date algorithms are always valid)



break on

global $rd_day,$rd_month,$rd_year,$rd_internal

$CurDefDate = readprofilestring("c:\program files\common files\symantec shared\virusdefs\definfo.dat""DefDates""CurDefs" )

$rd_year    = val(substr($CurDefDate14))
$rd_month   = val(substr($CurDefDate52))
$rd_day     = val(substr($CurDefDate72))

gosub "intdate"

$Def_Int    = $rd_internal

$rd_year    = @year
$rd_month   = @monthno
$rd_day     = @mdayno

gosub "intdate"

$Def_Age = $rd_internal - $Def_Int

"Virus definitions are " + $Def_Age + " Day(s) old"

get $key

exit 1

:intdate ;this is normally CALLed but for clarity I made it a SUB

;
; intdate.kix
;   Library routine to convert a date from Calendar to internal format.
;
;   The algorithm used here is taken directly from the following document:
;      http://www.capecod.net/~pbaum/date/date0.htm
;
; Variables passed:
;        rd_day      IN    Day of month (0-31)
;        rd_month    IN    Month of year (1-12)
;        rd_year     IN    Full year
;        rd_internal OUT   Internal representation
;
; Amendment history:
; Version 1.0 21 June 2000 Richard Howarth
;

dim $MyYear,$MyMonth
$MyYear  = $rd_year
$MyMonth = $rd_month
if $MyMonth < 3
    $MyMonth = $MyMonth + 12
    $MyYear  = $MyYear - 1
endif
$rd_internal = $rd_day + ( 153 * $MyMonth - 457 ) / 5 + 365 * $MyYear + $MyYear / 4 - $MyYear / 100 + $MyYear / 400 - 306

return



($Def_Age is the days between the .dat date and today)

hth
_________________________



Top
#38722 - 2003-04-04 02:07 PM Re: NAV Def files and Dates
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
DJ,

Please be aware that your code (NTDOC's above too) will definetly fail on certain dates !!!

I only say so much : LEAP YEARS !!!

[Big Grin]
_________________________



Top
#38723 - 2003-04-04 02:40 PM Re: NAV Def files and Dates
DJC Offline
Fresh Scripter

Registered: 2003-04-02
Posts: 8
Loc: UK
[Wink] This is fantastic, Exactly what i need. [Wink]
Thanks so much .. my faith in the computer has been restored
_________________________
Currently on : KiXtart 95 3.60

Top
#38724 - 2003-04-04 10:22 PM Re: NAV Def files and Dates
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Jochen.. The DATE math is not mine, and I even said I had doubts as to whether or not it was valid.

As for my code not working on v3.6x I doubt that too. All the code callouts are valid for v3.6x

In fact your specific call to a HARD CODED file location is an opportunity for the code to fail. Not blaming you, as you are only supplying what DJ gave you. However, a call to the REGISTRY should always find the correct information/location regardless of which drive it was installed on.

DJ... If you tried my code, it should work to at least tell you something. The math... is still all your code and I have not tested that.

Top
#38725 - 2003-04-04 10:25 PM Re: NAV Def files and Dates
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yap

Sorry Ron !
I didn't relaize that you just copied the math part [Big Grin]

Tsk tsk ... allthough I gave the link to Richards Subs in my first reply [Big Grin] [Wink]
_________________________



Top
#38726 - 2003-04-04 10:28 PM Re: NAV Def files and Dates
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Hey Jochen.. Okay, since no MSN

Please give me your best KiXtart v4.12+ code for doing the same task.

Top
#38727 - 2003-04-04 10:46 PM Re: NAV Def files and Dates
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Jochen... New request for PostPrep.

How about adding ability to change the FONT size.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 194 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.088 seconds in which 0.041 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org