I might have misunderstood, but in MikroTik there is a limitation on the size of the read and written files, which is 4 kB. This means that even a log file cannot be read by a script if it exceeds this size. Am I correct in understanding that one needs to somehow concatenate files when reading and split them when writing? Or is there another way to work with large files?
The limit reading the file from /file is 4095 Bytes, but by fetch is 64512 Bytes
But with my method, on supported hosts, the read is ulimited.
Is time you read and study my posts…
http://forum.mikrotik.com/t/how-to-download-only-one-piece-of-file-at-a-time-with-tool-fetch-and-put-it-inside-a-variable/151020/1
I continue to attribute our misunderstanding not to your unwillingness to listen, but to the poor translation, even though I'm using ChatGPT. I was not interested in reading from other websites. I was interested in writing a single large file, including when reading SMS messages from a modem. Even if you have only 25 SMS messages on a SIM card, they may not fit into one file under these circumstances. And if you have SMS messages stored in the modem's memory, where there can be a couple of hundred messages, they will definitely not fit into one file. Therefore, I was wondering if it's possible to write any file with any extension, such as .log or .abirval, as long as there is no need to split the file into parts. Splitting the file into parts is not a problem, and even concatenating the read content into one variable. I did that on the first day. But I wanted to write some logs, including having an array of read SMS messages.
MikroTik allows you to write a large-sized file if you copy it from a computer. However, it cannot be read without prior splitting. Moreover, the presence of an SSD slot on the router looks quite odd. Why is it there if MikroTik cannot read large files? I was hoping that there would be some recording format, some extension, or a way to write the necessary files onto such a disk.
This is the option I came up with on the first day when I started working on reading SMS. Files are read in a similar way. So there is no problem with splitting and reading. The inconvenience lies in the misunderstanding of MikroTik's policy. It's like wings on a chicken, they exist, but it can't fly over the fence.
:local output ( [ /interface lte at-chat lte1 wait=yes input="AT+CMGL=4" as-value ]->"output" );
:local lenOutput ([:len $output]);
:local condition 1;
:local i 0;
:local j 0;
:while ($condition=1) do={
    :local nameFile ("sms".$j.".txt")
    /file print file=$nameFile;
    :delay 3s;
    /file set $nameFile contents=[:pick $output $i ($i+4000)];
    :set i ($i + 4000);
    :if ($i < $lenOutput) do={
        :set j ($j +1)
        :set condition 1;
    } else={:set condition 0;}
}
You can read large files by not using a script to read the file but put the script in the file in a form of a function and import the RSC file.
Exporting large files is possible and rename it then to an RSC file so they can be imported again.
Exactly, if I wasn’t interested, I wouldn’t even have answered you.
But what is your native language?
The issue is not “a policy”, but the limit on the length of a string variable.
Because the command to read from a file can only read the entire file in one read and the result will have to fit in a variable, there is this limitation.
It would be easy to solve, by providing separate open/read/close commands where read would read some specified data (#bytes, “a line”) and can be called in a loop after open to process all data in the file record-by-record.
Unfortunately RouterOS does not provide that.  It has been in the feature suggestions for a long time.
Now, when you want to read “the log”, it can be done in a different way because you can get records one-by-one from the log memory buffer.
In the end it’s just RouterOS, not “eXtendedOS”.
Either you use Containers so you do what you like, or you accept that in the end it’s a Router, not one Synology or one of the many “SIM Manager” programs…
Can you give a couple of links to this topic to read more and understand it?
I understand that RouterOS is designed specifically for routers (and possibly single-board computers). I don't have excessive demands for it. However, if the manufacturer claims to support certain hardware, it would be desirable to have full support rather than limited functionality. Especially since we are not only talking about reading SMS messages.
I think it's not important, even though I live in one country, my native language is different. Overall, I've gotten used to the fact that Google has been doing a poor job of translating my native language in the past couple of years. Even AliExpress started providing bad translations in my native language. But I'm not blaming my country or Google. Maybe there are fewer specialists who know my language now. And there are fewer people who need my native language. There used to be more of us, but times change and everything evolves.
[…]
This was the startingpoint: http://forum.mikrotik.com/t/send-script-output-to-a-file/116250/14
Let’s sort it out…
- 
Read an internal file to the RouterBOARD. 
 a) Reading the contents of any file into /files and putting it into a variable is limited to 4095Bytes.
 b) Reading the contents of any file into /files and auto-sharing it as a file in ftp and putting it into a variable, is limited to 64512Bytes.
- 
Read an external file to the RouterBOARD. 
 a) Reading the content of any file via http,https and ftp and putting it in a variable is limited to 64512Bytes.
 b) It is possible to read longer files, one piece at a time, with my method on http and https only.
- 
Read content (from a file) at most large 65452Bytes (is limited to 30000Bytes if the field is filled on WinBox textarea field). 
 a) It is possible to read/write from a particular area of RouterOS, as if it were a reserved area,
 but inevitably the data is read by doing an “import” and written by doing an “export”.
 This zone is the “Startup Note” zone.
 If you don’t plan to use it, it provides easy import and export, which is not even mixed with schedulers or scripts,
 so that you only export/import what you want, so you don’t export other schedulers and scripts to the file as well.
 Example of one export/import:
jun/20/2023 17:05:40 by RouterOS 6.48.6
software id = DEKE-RIJB
model = SXT G-5HPacD r2
serial number = DEADBEEFC1AX
/system note
set note=“12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\r
\n12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\r
[…] 651 identical lines removed
\n12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\r
\n12345678901234567890123456789012345678901234567890\r
\n” show-at-login=no
For read, just import the file (no matter if have or not .rsc extension) and you can have the correct content with :local varname [/sys note get note]
So, in conclusion for READ section, 65452Bytes can contain without problem 256 SMS.
I guess all (or most) these DyadyaGenya topics will not be necessary if sms tool is improved - http://forum.mikrotik.com/t/sms-tool-improvements/163144/1 it was my first topic on this forum, I should probably need to add link to it into feature request topic.
Very strange. I don't understand that case, but I can read a file that I may have copied from the computer to the Mikrotik and which has a size of 6.4 KiB. I do like this:
:local sms [ /file get [ find name="sms.txt" ] contents ]
:put $sms
But nothing is printed. If I reduce the file size to 4KiB, then everything works out.
Or is this case related to point "a"?
Not interested at the moment
and
and
I didn't understand this example. Let's say I did this:
/system note set note  ( [ /interface lte at-chat lte1 wait=yes input="AT+CMGL=4" as-value ]->"output" );
How can I write this to the "sms.txt" file?
And how then to read this file?
Still interested in how many such files can be created and where are they stored? Can I create such files on an ssd drive? Because I would like to write not only SMS, but also to make a safety net for IoT records.
I subscribe to your every word. This is exactly what I was talking about when comparing chicken wings. Yes, chickens are good birds. There are many benefits from it: meat, eggs, feathers, the opportunity to show care. But Mikrotik claims to be an eagle. Indeed, in many areas he behaves like an eagle. But there are moments when he turns into a chicken that does not fly higher than the fence, although there are wings.
I think that it is more correct to continue in this topic, and not in the one where the link is.
I tried doing something like this:
:local sms [/system script get "sms.txt" source]; 
:put $sms
But it gives an error: “no such item”
Probably when you ask MikroTik for SMS support, you will get the reply “nobody uses SMS anymore, we all use Telegram”.
It is similar to the request to support DSL (through other people’s hardware) that is waved away with “everyone has fiber today”.
They seem to see the local Latvian situation as leading for the entire world…
I’d say Mikrotik is more a magpie (good luck, bad luck, or a pest…depending on context) than eagle – but liked the analogy.
@rextended feel free to correct me  .  But “/file x set content=$mytest” is limited to 4k chars.  Part of this is because RouterOS variables are really UNIX shell variable – which used to be limited to 4K but now 32K or large in modern Linux.  Mikrotik allows up to 32K someplaces, but not in /file – so RouterOS is a chicken when it comes to /file.
.  But “/file x set content=$mytest” is limited to 4k chars.  Part of this is because RouterOS variables are really UNIX shell variable – which used to be limited to 4K but now 32K or large in modern Linux.  Mikrotik allows up to 32K someplaces, but not in /file – so RouterOS is a chicken when it comes to /file.
The only way around this is some “scripting trickery” since commands that right don’t go through /file with variables aren’t limited in size – @rextended has some suggestions, all complex because of the scripting limitations – so don’t shoot the pigeon with the message. But I think it the /file operations that enforces this artificial 4K limit, so no way around that part. At some point you’ll run into the “real” limit of 32K however.
And, yes, it’s fair question now that Mikrotik sells many LTE devices why they don’t parse PDUs as part of /tool/sms.
Yes, sadly. There are advanced features like parsing commands from message body, but not basics like Unicode encoding and segmented messages support.
Well, changing the 4K file limit from content= be a start… @DyadyaGenya and @rextended have come a long way here… to run into yet another limitation & another set of complex scripting to workaround.