In RouterOS 7.10+ the text string formatted as "2024-06-06 09:35:52" simply converted to time by :totime command. :put [:totime "2024-06-06 09:35:52"] But this conversion occurs without taking into account the local time zone. To take into account the local time zone, you can do this: :put ([:totime "2024-06-06 09:35:52"] - [:totime [/system clock get gmt-offset]]) If you want to convert time to number of seconds since 1970-01-01 unix concept - you can use :tonum command
What I would love to see is ansible netcommon network_cli module with a propper mikrotik.ros.ros_* functions to abstract different configurations to allow for easy vendor transition. The bigger ones like Cisco with IOS/NXOS or Arista all have modules using the same functions such taht I don't need to rewrite the entire code all the time.
@@mikrotik I'll add another interesting observation. If we :put the result of a function that should be returns a "nothing", we will see the "nil". Moreover, inside the function itself it will still be a "nothing", and when substituting the return in the :put commanf, we will already see an "nil" :local testFunc do={ :local var; :put ("Inside function is: ".[:typeof $var]); :return $var; }; :put ("Outside function is: ".[:typeof [$testFunc]]); Result: Inside function is: nothing Outside function is: nil I think type damage occurs in the process of substituting using square brackets. This nuance causes another problem: The :nothing command is designed to produce the data type "nothing" and does it successfully. But to use this command in a script, it needs to be wrapped in square brackets so that the value is substituted, and this process convert it to the "nil". :put [:typeof [:nothing]]; Result: nil We get that the system has a command that in practical form cannot produce the intended result. I wrote a ticket about this problem, but support did not accept the arguments. P.S. For example: A simple method to substitute a real "nothing" into an expression is :put [:typeof (:)]; A simple method to substitute a "nil" into an expression is :put [:typeof []];
At that point, you'd get people wanting to have JavaScript as well, and Go, and Rust and because not everyone likes Python. I think it's best to just stick to the DSL they have created for RouterOS and if you really want to use Python, write a wrapper and run it in a container or something.
How to convert in ROS7 time from format [2024-06-06 09:35:52] to unixtime, may be some function exist ?
In RouterOS 7.10+ the text string formatted as "2024-06-06 09:35:52" simply converted to time by :totime command.
:put [:totime "2024-06-06 09:35:52"]
But this conversion occurs without taking into account the local time zone.
To take into account the local time zone, you can do this:
:put ([:totime "2024-06-06 09:35:52"] - [:totime [/system clock get gmt-offset]])
If you want to convert time to number of seconds since 1970-01-01 unix concept - you can use :tonum command
But you are absolutely right in the sense that everything is very bad with the concept of "time" in the RouterOS.
Especially in the Logs.
What I would love to see is ansible netcommon network_cli module with a propper mikrotik.ros.ros_* functions to abstract different configurations to allow for easy vendor transition.
The bigger ones like Cisco with IOS/NXOS or Arista all have modules using the same functions such taht I don't need to rewrite the entire code all the time.
Pls fix L11 Does not wrk with RB911-5HacD on longer distance then 50m. Even L11 and L11 do nto work.
What SSH client are you using next to VS Code there? Extension or another app? And if so, which extension?
Just an OpenSSH client :)
"nothing" and "nil" not same equal. :local var1; :local var2 []; :put [:typeof $var1]; :put [:typeof $var2];
Thank you for pointing that out, that's an interesting nuance.
@@mikrotik I'll add another interesting observation.
If we :put the result of a function that should be returns a "nothing", we will see the "nil".
Moreover, inside the function itself it will still be a "nothing", and when substituting the return in the :put commanf, we will already see an "nil"
:local testFunc do={ :local var; :put ("Inside function is: ".[:typeof $var]); :return $var; }; :put ("Outside function is: ".[:typeof [$testFunc]]);
Result:
Inside function is: nothing
Outside function is: nil
I think type damage occurs in the process of substituting using square brackets.
This nuance causes another problem:
The :nothing command is designed to produce the data type "nothing" and does it successfully.
But to use this command in a script, it needs to be wrapped in square brackets so that the value is substituted, and this process convert it to the "nil".
:put [:typeof [:nothing]];
Result:
nil
We get that the system has a command that in practical form cannot produce the intended result.
I wrote a ticket about this problem, but support did not accept the arguments.
P.S. For example:
A simple method to substitute a real "nothing" into an expression is
:put [:typeof (:)];
A simple method to substitute a "nil" into an expression is
:put [:typeof []];
Scripting on MT has been slow as molasses, does one consider implementing JIT compiling of these scripts for that platform?
Not at this time.
There must be a way of errors diagnostic
Because now if your script doesn't work, you will never know why
we need python in mikrotik
What would you do in python that you can't in RouterOS?
At that point, you'd get people wanting to have JavaScript as well, and Go, and Rust and because not everyone likes Python.
I think it's best to just stick to the DSL they have created for RouterOS and if you really want to use Python, write a wrapper and run it in a container or something.
@@mikrotik lots of people know python and it's well documented. so what would you do? save time by not having to learn another language.