I came across this excellent piece of code that was posted by Bryce. I would like to do the following but I am having little success:

1. On the first run store the responses to an ini file.
2. After 5 minutes read and display the historic data stored in (1) above.
3. Overwrite (1) above with the current responses.
4. Repeat.

The trouble I am having is in the timing logic. Any help here would be greatly appreciated.

code:
 
break on cls
;--------------------------------------------------------------------------------------------------------
;WanReport.kix
;
; This script will ping a list of ip#'s displaying the status of each connection.
;
; Create a comma delimited file in the following format.
; <Common name>,<ipadress>
; <Common name>,<ipadress>
; <Common name>,<ipadress>
; ...
;
; Example: (the numbers have been changed to protect the innocent, please use FULL IP#'s)
; Arlington Super Store,10.9.x.x
; Arrowhead Crossing,10.9.x.x
; Auburn Hills,10.9.191.x.x
; Baybrook Super Store,10.9.x.x
;--------------------------------------------------------------------------------------------------------
$file = "wanrouters.csv" ;CSV database of ip#'s to scan
$sleep_Min = 1 ;Number of minutes between scans
$timeOut = "3000" ;The max ping timeout
$fast = 95 ;Ping time is MS, used for color codes
$slow = 350 ;Ping time is MS, used for color codes

$temp = "%temp%\temp.dat"
;--------------------------------------------------------------------------------------------------------
$sleep_min = $sleep_Min*60

:top
$line = 1
$col2 = 10
$col3 = 45

If exist($file) = 1
copy "$file" "%temp%\wanrouters.csv"
else
? "Could not find $file. Script ending"
exit
endif

$nul = open(1,"%temp%\$file",2)
$data = readline(1)

at($line,0) 'Press ' color y+/n '"CTRL-C"' color w/n ' to Exit, AUTO repeat set to $sleep_Min seconds' $line = $line + 1

do
$Store = substr("$data",1,instr("$data",",")-1)
$Store_Router = substr("$data",instr("$data",",")+1,len("$data"))

Shell'%comspec% /c ping -n 1 -w $timeout $Store_Router | find "Reply" > "$temp"'
$q = open(2,"$temp",2) $reply = readline(2) $q = close(2)
if $reply <> ""
$reply_time = substr("$reply",instr("$reply","time")+4,instr("$reply","TTL=")-instr("$reply","time")-5)
at($line+1,0)" "
at($line,0)color g/n "OK" color w/n
select
case val(substr("$reply_time",2,instr("$reply_time","ms"))) <= $fast
color g+/n
case val(substr("$reply_time",2,instr("$reply_time","ms"))) <= $slow
color y+/n
case val(substr("$reply_time",2,instr("$reply_time","ms"))) > $slow
color r+/n
endselect
select
case substr("$reply_Time",1,1) = "="
" " substr("$reply_Time",2,len("$reply_Time")-1) color w/n
case substr("$reply_Time",1,1) = "<"
" $reply_Time" color w/n
endselect
at($line,$col2)"$store" At($line,$col3)"$Store_Router" $line = $line + 1
else
at($line+1,0)" "
at($line,0)color r+/n "TIMEOUT!" color w/n at($line,$col2)"$store" at($line,$col3)"$Store_Router" $line = $line + 1
endif
$data = readline(1)
until @error <> 0
$nul = close(1)
del "$temp"
? "Sleeping for " $sleep_min "sec"
Sleep $sleep_Min
goto top
exit