Personally I will go with approach: In loop where records are appended to variable for file save, before append record to that variable I will first check size of that variable and if that length of that variable + length of record variable exceeds 4K then I will write current content value into file segment, then assign current record variable into that variable. File segment counter needs to be raised each time when file is saved. At the end you will have files like: sms.txt.1, sms.txt.2, sms.txt.3… which can be merged on other system where are downloaded.
Why consider the volume of a variable, if everything is well written to a file without it. Have you seen my example above? There is exactly the same principle as you described, only without checking the volume of the variable.
I do not argue, the example is not very well designed, but it was one of the first scripts that I wrote and I published it here just so that the @rextended understood what I was talking about.
Well that is not exactly, that part is crucial if you don’t want to reach 4k limit. Topic is The maximum size of a read/written file. which is actually limit of variable that contains content of a file.
I saw your script example, yes it contains loop for writing file segments, but it is lacking logic which I mentioned.
@optio Why still self limit to 4096 bytes!? Many people here walked into this limitation for many years and some found little gems in RouterOS which works around problems. One of those is “:execute”
Lets keep it simple, this will store the output of a command or script to a file like it was display in you screen.
:execute "/ip/route/export" file="test"
It adds the default extension “txt” to the filename, here is that “test”
What does it have to do with it, I wanted him to specify it, if he wanted...
If you look closely you'll see that the Uncle Женя lives in Chernihiv, and was born on January 17.. (Женя жарт... )
I don't put the year, if he wants he can put it there...
In fact, both options work. And if you tell me how to read the received files, then this will be an almost ideal solution. I write “almost” because for some reason (maybe it’s something wrong with me) after rebooting the router, the file disappears. It has to be copied to another location or renamed.
That depends on the type of router. Unfortunately, MikroTik has missed the chance of defining standard paths of persistent/volatile files.
Now, you will have to check yourself and use a path suitable for your router type and configuration.