File Size Limit - 4096

Hi

I am using a script to write HotSpot user data to a text file on the router however, I am having an issue with the 4096 file size limit. I cannot believe that this has not been solved yet, does anyone know of any workarounds other than writing to multiple files?

What is strange that if I print a list of the /file contents to a text file, the router allows a larger file than 4096.

Regards

It is limit not to file - it is limit for variable size…
If you write text variable to file - you can write maximum 4096 bytes.
Problem that ROS haven’t normal file input/output (i.e. you can’t just append to file or read line by line).
But!!! %)))
You can output to file output of script - in such case size is not limited.
For example, running this script produces ~70Kb file:

:local s ":for i from=0 to=1000 do={:put \"ghkjhkjhkjhkjhkjhkjhkjhkjhkjhkjhkjhkjhkjhkjjhkjhkjjhkjhkjhkjhkjjhkjh\"}"
:execute script=$s file=testOut

Trick uses “execute” parameter “file”:

[admin@Primary] > /execute ?
<script> -- source of script to execute in background
[b]file -- write script output to file[/b]

Now you just must write script which produces needed information to conslole and redirect this output to file via “execute”.
PS: yes, simple things are not so simple in ROS yet.

Hi

Thanks so much! I have played around with it and it works.

I have tried to use this with my script, but I keep getting an error " expected end of command (line 1 column 3)" that is written to the $filename. I suspect it has something to do with the foreach loop, but am not able to fix it after reading up on similar issues.

Any thoughts?

###Variables###
:local counter
:local datadown
:local dataup
:local filename "usageTest1.txt"


###Get hotspot user info###
:foreach counter in=[/ip hotspot user find profile="default" ] do={
:local macaddress [/ip hotspot user get $counter mac-address]
:local uptime  [/ip hotspot user get $counter uptime]
:set datadown [/ip hotspot user get $counter bytes-out]
:set dataup [/ip hotspot user get $counter bytes-in]
:local datadownMB ($datadown /1024 /1024)
:local dataupMB ($dataup /1024 /1024)
:local datatotalMB ($datadownMB + $dataupMB)

###Write to file###
:local write2file ($macaddress."-".$datatotalMB ."MB"."-".$uptime."\r\n")

:local script2write "do={:put $write2file}"
:execute script=$script2write file=$filename
}
###Variables###

:local filename "usageTest1.txt"


###Get hotspot user info###

:local script2write  "
:local counter;
:local datadown;
:local dataup;
:foreach counter in=[/ip hotspot user find profile=\"default\" ] do={
  :local macaddress [/ip hotspot user get \$counter mac-address];
  :local uptime  [/ip hotspot user get \$counter uptime];
  :set datadown [/ip hotspot user get \$counter bytes-out];
  :set dataup [/ip hotspot user get \$counter bytes-in];
  :local datadownMB (\$datadown /1024 /1024);
  :local dataupMB (\$dataup /1024 /1024);
  :local datatotalMB (\$datadownMB + \$dataupMB);
  :put \" \$macaddress - \$datatotalMB MB - \$uptime \r\n\";
}"
  :put $script2write;
  :execute script=$script2write file=$filename

Here you have your code rewritten, it’s working fine.

Thanks a lot, it works!