Scripting: variable data types

Поделиться
HTML-код
  • Опубликовано: 13 сен 2024

Комментарии • 17

  • @kossfort1848
    @kossfort1848 3 месяца назад +3

    How to convert in ROS7 time from format [2024-06-06 09:35:52] to unixtime, may be some function exist ?

    • @FlyDvorkin
      @FlyDvorkin 2 месяца назад

      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

    • @FlyDvorkin
      @FlyDvorkin 2 месяца назад

      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.

  • @FlaxTheSeedOne
    @FlaxTheSeedOne 3 месяца назад

    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.

  • @ussul6524
    @ussul6524 3 месяца назад

    Pls fix L11 Does not wrk with RB911-5HacD on longer distance then 50m. Even L11 and L11 do nto work.

  • @X0mbiRapt0r
    @X0mbiRapt0r 3 месяца назад

    What SSH client are you using next to VS Code there? Extension or another app? And if so, which extension?

    • @mikrotik
      @mikrotik  3 месяца назад +1

      Just an OpenSSH client :)

  • @FlyDvorkin
    @FlyDvorkin 3 месяца назад +1

    "nothing" and "nil" not same equal. :local var1; :local var2 []; :put [:typeof $var1]; :put [:typeof $var2];

    • @mikrotik
      @mikrotik  3 месяца назад +1

      Thank you for pointing that out, that's an interesting nuance.

    • @FlyDvorkin
      @FlyDvorkin 3 месяца назад

      @@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 []];

  • @ivosarak959
    @ivosarak959 3 месяца назад

    Scripting on MT has been slow as molasses, does one consider implementing JIT compiling of these scripts for that platform?

    • @mikrotik
      @mikrotik  3 месяца назад +2

      Not at this time.

  • @olpchk1115
    @olpchk1115 3 месяца назад

    There must be a way of errors diagnostic
    Because now if your script doesn't work, you will never know why

  • @mohamadbaghdadi3612
    @mohamadbaghdadi3612 3 месяца назад +1

    we need python in mikrotik

    • @mikrotik
      @mikrotik  3 месяца назад +2

      What would you do in python that you can't in RouterOS?

    • @FinlayDaG33k
      @FinlayDaG33k 3 месяца назад +5

      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.

    • @kchiem
      @kchiem 3 месяца назад

      @@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.