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.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..........................
viewtopic.php?f=9&t=177530
: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;}
}
Exactly, if I wasn't interested, I wouldn't even have answered you.I continue to attribute our misunderstanding not to your unwillingness to listen, but to the poor translation
Can you give a couple of links to this topic to read more and understand it?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.
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.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....
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.Exactly, if I wasn't interested, I wouldn't even have answered you.
But what is your native language?
# 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=noFor 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]
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: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.
:local sms [ /file get [ find name="sms.txt" ] contents ]
:put $sms
Not interested at the moment2) Read an external file to the RouterBOARD.
and3) Read content (from a file) at most large 65452Bytes (is limited to 30000Bytes if the field is filled on WinBox textarea field).
andexample big file export code
/system note set note="..."
I didn't understand this example. Let's say I did this: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]
/system note set note ( [ /interface lte at-chat lte1 wait=yes input="AT+CMGL=4" as-value ]->"output" );
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 guess all (or most) these DyadyaGenya topics will not be unnecessary if sms tool is improved - viewtopic.php?t=191963, it was my first topic on this forum, I should probably need to add link to it into feature request topic.
I think that it is more correct to continue in this topic, and not in the one where the link is.This was the startingpoint: viewtopic.php?p=819118
:local sms [/system script get "sms.txt" source];
:put $sms
Yes, sadly. There are advanced features like parsing commands from message body, but not basics like Unicode encoding and segmented messages support.And, yes, it's fair question now that Mikrotik sells many LTE devices why they don't parse PDUs as part of /tool/sms.
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.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.
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.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.
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.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 saw your script example, yes it contains loop for writing file segments, but it is lacking logic which I mentioned.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.
I think that it is more correct to continue in this topic, and not in the one where the link is.This was the startingpoint: viewtopic.php?p=819118
I tried doing something like this:But it gives an error: "no such item"Code: Select all:local sms [/system script get "sms.txt" source]; :put $sms
execute "/system script get \"sms.txt\" source" file="sms.txt"
:local output ( [ /interface lte at-chat lte1 wait=yes input="AT+CMGL=4" as-value ]->"output" )
:local lenOutput [:len $output]
:local splitSize 4095
:local offset 0
:local part 1
:while ($offset < $lenOutput) do={
:local nameFile ("sms".$part.".txt")
:if (($offset + $splitSize) > $lenOutput) do={
/file add name=$nameFile contents=[:pick $output $offset $lenOutput]
:set offset $lenOutput
} else={
/file add name=$nameFile contents=[:pick $output $offset ($offset + $splitSize)]
:set offset ($offset + $splitSize)
}
:set part ($part + 1)
}
:execute "/ip/route/export" file="test"
Ok, from DyadyaGenya script example correct answer will be then@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.
It adds the default extension "txt" to the filename, here is that "test"Code: Select all:execute "/ip/route/export" file="test"
You can find more about :execute: https://wiki.mikrotik.com/wiki/Manual:S ... l_commands
:execute ":put ([/interface lte at-chat lte1 wait=yes input=\"AT+CMGL=4\" as-value ]->\"output\")" file=sms.txt
This may answer https://forummikrotik.ru/viewtopic.php?p=89403#p89403But what is your native language?
LOL. About the same...This may answer https://forummikrotik.ru/viewtopic.php?p=89403#p89403But what is your native language?
(Google tells me, that means "Everything is written above. Those who have eyes will see.")Всё написано выше. Имеющий глаза - увидит
What does it have to do with it, I wanted him to specify it, if he wanted...This may answer https://forummikrotik.ru/viewtopic.php?p=89403#p89403But what is your native language?
Ok, from DyadyaGenya script example correct answer will be then@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.
It adds the default extension "txt" to the filename, here is that "test"Code: Select all:execute "/ip/route/export" file="test"
You can find more about :execute: https://wiki.mikrotik.com/wiki/Manual:S ... l_commands
Code: Select all:execute ":put ([/interface lte at-chat lte1 wait=yes input=\"AT+CMGL=4\" as-value ]->\"output\")" file=sms.txt
:execute ":put ([/interface lte at-chat lte1 wait=yes input=\"AT+CMGL=4\" as-value ]->\"output\")" file="sms"
Works also with .txt extension in file param, then it will not append .txt to filename.Code: Select all:execute ":put ([/interface lte at-chat lte1 wait=yes input=\"AT+CMGL=4\" as-value ]->\"output\")" file="sms"
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.No, I wrote "It adds the default extension "txt" to the filename, here is that "test" ".
Code: Select all:execute ":put ([/interface lte at-chat lte1 wait=yes input=\"AT+CMGL=4\" as-value ]->\"output\")" file="sms"
Not overhere on ROS 7.10Works also with .txt extension in file param, then it will not append .txt to filename.Code: Select all:execute ":put ([/interface lte at-chat lte1 wait=yes input=\"AT+CMGL=4\" as-value ]->\"output\")" file="sms"
I'm also on 7.10Not overhere on ROS 7.10
> /system/routerboard/print
routerboard: yes
model: D53G-5HacD2HnD
serial-number: XXXXXXXX
firmware-type: ipq4000L
factory-firmware: 7.1beta5
current-firmware: 7.10
upgrade-firmware: 7.10
> :execute ":put ([/interface lte at-chat lte1 wait=yes input=\"AT+CMGL=4\" as-value ]->\"output\")" file="sms.txt"
Already explained above viewtopic.php?t=197190#p1008826 and system note can be used as workaround. You can also provide file over http and use chunked download with fetch tool, also you have post with script by rextended viewtopic.php?f=9&t=177530In fact, both options work. And if you tell me how to read the received files, then this will be an almost ideal solution.
you can use flash of usb storage for persistence, depends on device, to save it on flash useI 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.
file="flash/sms"
I checked again and you are correct. I mixed up that by having then a extra extension to the filename "sms.file" --> "sys.file.txt"I'm also on 7.10Not overhere on ROS 7.10
sms_file.pngCode: Select all> /system/routerboard/print routerboard: yes model: D53G-5HacD2HnD serial-number: XXXXXXXX firmware-type: ipq4000L factory-firmware: 7.1beta5 current-firmware: 7.10 upgrade-firmware: 7.10 > :execute ":put ([/interface lte at-chat lte1 wait=yes input=\"AT+CMGL=4\" as-value ]->\"output\")" file="sms.txt"
Yes, for other extensions is appended, but for txt not.I checked again and you are correct. I mixed up that by having then a extra extension to the filename "sms.file" --> "sys.file.txt"
{
:local filename "readallsmspdu.txt"
:if ([:len [/file find where name="flash" and type="disk"]]=1) do={:set filename "flash/$filename"}
:local jobID [:execute ":put ([/interface lte at-chat ([find]->0) input=\"AT+CMGF=0;+CMGL=4\" wait=yes as-value ]->\"output\")" file=$filename]
:while ([:len [/system script job find where .id=$jobID]] > 0) do={
:delay 1s
}
}
You didn't guess my native language correctly ))) I appreciate your tact, even if it wasn't fully demonstrated. As I mentioned earlier, I don't consider nationality, language, age, or other characteristics to be important. People should be judged by their actions, not by their language or age.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...
I tried it. Firstly, the pros. It seems visually faster and creates two files at once. As for the cons, there is more code and more "extra movements." But extra movements are a matter of personal preference.@DyadyaGenya try with this
I hope that your little investigation brought you moral satisfaction and perhaps even physical satisfaction.This may answer https://forummikrotik.ru/viewtopic.php?p=89403#p89403But what is your native language?
That's why I mentioned tact. I don't know how the translator will render it, so let me explain it in different words. Don't feel compelled to voice everything you know.Do you really think I give a damn if you're Russian, Polish or Ukrainian?
Naturally, I tried that option right away. I saved the file to my SSD drive. It doesn't matter, after rebooting, it still disappears.you can use flash of usb storage for persistence, depends on device, to save it on flash useCode: Select allfile="flash/sms"
The sentence, on purpose, was meant to be negative, to give the appropriate emphasis to the concept: "I just keep seeing a Brother.".in one of them, it has a very negative meaning ))))Do you really think I give a damn if you're Russian, Polish or Ukrainian?
No, just curiosity was raised when you complaining about understanding google/chat gpt translations and unwillingness to reveal you natural language. I thought maybe you speak Njerep but translation of you nick guided me to russian forum and thats about it.I hope that your little investigation brought you moral satisfaction and perhaps even physical satisfaction.
Everything is fine, I understand simple things without a translator. And I understand where the translator is likely to make mistakes, so I constantly talk about the issue of understanding and don't blame the person for inaccuracies.The sentence, on purpose, was meant to be negative, to give the appropriate emphasis to the concept: "I just keep seeing a Brother.".
in one of them, it has a very negative meaning ))))
I still don't understand how to read such a file. You're talking about exporting, and as I understood, using notes, but I still couldn't accomplish it.This work for sure, but the file is created after some seconds, or you wait ":execute" to finish it's job, or you do not see instantly the file...
It is hard to understand what you want to accomplish with all this. First if you you want to save PDU to file then it seems you want to be read on other system, but you want also read PDU from file, what case is that? You use external system to modify that file and again to be read inside ROS, why just not process PDU on that system? If external system is not involved here, why using files anyway? You want to create some kind of SMS inbox with ROS script so that you can have in it more that 25 messages? If that is the case, I suggest to create something in container and download over ftp PDU file in some interval and create scheduler that saves that saves PDU in file and erases messages from SIM.I still don't understand how to read such a file. You're talking about exporting, and as I understood, using notes, but I still couldn't accomplish it.
:if ([find where name=<filename>]) do={...}
:local output ( [ /interface lte at-chat lte1 wait=yes input="AT+CMGL=4" as-value ]->"output" )
:local lenOutput [:len $output]
:local splitSize 4095
:local offset 0
:local part 1
/file
:while ($offset < $lenOutput) do={
:local nameFile ("sms".$part.".txt")
:local end
:if (($offset + $splitSize) > $lenOutput) do={
:set end $lenOutput
} else={
:set end ($offset + $splitSize)
:set part ($part + 1)
}
add name=$nameFile contents=[:pick $output $offset $end]
:set offset $end
}
:local part 1
:local input ""
:local done false
/file
:while (!$done) do={
:local nameFile ("sms".$part.".txt")
:if ([find where name=$nameFile]) do={
:set input ($input.[get $nameFile contents])
:set part ($part + 1)
} else={
:set done true
}
}
:put $input
It's probably my fault that I didn't describe in detail what I want. I have several objectives: 1. Occasionally save the contents of PDU to a file. 2. Occasionally save processed SMS to another file. 3. Sometimes save data from smart home devices to a third file. 4. Occasionally save incoming Telegram messages to multiple files. These messages can be related to modem operations as well as IoT device operations. 5. Accordingly, depending on the situation, it is necessary to periodically append data to one of these files.It is hard to understand what you want to accomplish with all this.
It was explained in above posts why you can't and that you can only load chunked/segmented data into script variable. If you need to load large file from external system you can provide it over http and fetch it chunked or split file into segments and upload to device.By the way, the option with "execute" for writing suits me just fine. But I don't understand if it allows appending and how to read from it
I don't understand what you mean by an external system. Are you referring to my mention of IoT devices? These devices send brief information in small messages. Since it's not possible to create SQL databases on MikroTik, I wanted to save this data in CSV or JSON format. This doesn't require transmitting large amounts of information over HTTP.If you need to load large file from external system you can provide it over http and fetch it chunked or split file into segments and upload to device.
The data will definitely be transmitted and stored on another system, which will be the main system. However, I hope to create a sufficiently resilient system with multiple safeguards. And I hope that one of those safeguards will be MikroTik. In this regard, I recall the Italian Arduino and its Chinese clones. They can easily write and read files of large sizes, although they are not full-fledged systems compared to the MikroTik processor.(for this you can use :execute and save all data into single file) over ftp that can be fetched from other system.
I have already inquired about log files, but no one has explained to me specifically what can be done with them and how. And yes, if we are talking about SMS, I would like to record all the data, including the timestamp. The same applies if I am saving data from IoT devices.One way of "appending" to a file that may be suitable for your purpose is to use /log to log the message at some severity, and define a logging action and corresponding logging destination (for that severity and "script" topic) to write these messages to a file.
Of course it will put date/time on the messages but you may even want that.
/system logging action
add disk-file-count=10 disk-file-name=atlog disk-lines-per-file=1000 name=atlog target=disk
/system logging
add action=atlog topics=gsm,info,!debug
Safeguards regarding networking is MikroTik device domain, but for some advanced approach of data processing which will be provided to main system, I will suggest to run/create some software/scripts in container which is also on same device but you have more flexibility/ability to process data there and deliver to main system, if you have such device that can run containers.The data will definitely be transmitted and stored on another system, which will be the main system. However, I hope to create a sufficiently resilient system with multiple safeguards. And I hope that one of those safeguards will be MikroTik.
Then it is not data file, it is a script with data variable. Also if data need to be imported from other system then there needs to be generated with script syntax so that can be loaded, just masochism...:execute allows to put serveral different stuff in one file. The file is then self contained and does need a external script to run, it uses the import command in ROS.
Indeed if all routers are on ROS...That's makes it ideal for distribution of data to many routers.
I mentioned it because maybe not everybody has all routers from same brand or when you want just to process same data on other system, doesn't need to be a router system. I will personally rather then process such data in container than additionally convert it into script syntax just for ROS. Ofc. depends on purpose, in some cases maybe it will not be possible to do something from containers, eg. to process large JSON or CSV and create some rules on ROS from it, but for PDU processing which is context of this topic it doesn't matter if processing is done in container with untouched content.I meant for Asus routers. Wrong forum I see now. Sorry.
I have a vague understanding of what a container is. Could you provide a couple of links where, in your opinion, it is explained in beginner-friendly language?Safeguards regarding networking is MikroTik device domain, but for some advanced approach of data processing which will be provided to main system, I will suggest to run/create some software/scripts in container which is also on same device but you have more flexibility/ability to process data there and deliver to main system, if you have such device that can run containers.
https://help.mikrotik.com/docs/display/ROS/ContainerI have a vague understanding of what a container is. Could you provide a couple of links where, in your opinion, it is explained in beginner-friendly language?
:execute script file=filename
:global tempData $data;
:execute script={ :global tempData; :put $tempData; :set tempData; } file=filename
:local fileContent ( [ /tool fetch url=( "ftp://127.0.0.1/" . $fileName ) user="login" password="password" port=21 mode=ftp as-value output=user ]->"data" );
:log debug message=";$yourVariable"
:local Contents [/file/get [find name=$FileName] contents]
# add some stuff to contents
/file set $FileName contents=$Contents