Wed Dec 10, 2008 5:09 pm
what I want to do ...
keep track of how much data is downloaded/uploaded per hour.
I have a script now that gets the information from the registration table and writes it a file.
:local debug 0
:local s1 " "
:local s2 " "
:local d1 " "
:local byte1 " "
:local backupfile ( [/system clock get date] . "---". [/system clock get time])
:foreach i in=[/interface wireless registration-table find] do= {
:local cbyte [/interface wireless registration-table get $i bytes]
# split the data bytes into two parts ... downloaded and uploaded
:local pos1 [:find $cbyte "," -1]
:local byte1 [:pick $cbyte 0 $pos1]
:set s1 ( $byte1 )
:set pos1 ( pos1 +1 )
:local s2 [:pick $cbyte $pos1 20]
:set s1 ( s1 . $s2 . " " . $backupfile )
:local content [ /file get data_used.txt contents]
:set content ( content . " \r\n" . $s1 )
/file set data_used.txt contents=$content
# /interface wireless registration-table reset $i
}
this is working for me ....
Now my problem is it quits working when the file size is 4026 B.
Question: is there a way to "APPEND" the new information to the file ... as opposed to reading the file into one variable and then rewriting the entire file?