Community discussions

MikroTik App
 
Anza
just joined
Topic Author
Posts: 1
Joined: Thu Jun 01, 2023 8:37 pm

WiFI SSID Width current datetime

Thu Jun 01, 2023 8:41 pm

Hi to all,
I need to rename the wifi SSID with a partial date time, but I have some difficul with parse and variable:

:local date [/system clock get date];
:local months {"jan"="01";"feb"="02";"mar"="03";"apr"="04";"may"="05";"jun"="06";"jul"="07";"aug"="08";"sep"="09";"oct"=10;"nov"=11;"dec"=12};
:local day [:tonum [:pick $date 4 6]];:local year [:tonum [:pick $date 7 11]];:local month [:pick $date 0 3];:local mm (:$months->$month);
:local newdate "$year-$mm-$day";
/interface wireless set wlan1 ssid=“newwifi" + newdate
 
holvoetn
Forum Guru
Forum Guru
Posts: 5327
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: WiFI SSID Width current datetime

Thu Jun 08, 2023 9:53 pm

Use this as a base, perhaps ?
Offered by our house cat Rex :lol:

viewtopic.php?p=934798#p934798
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11968
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: WiFI SSID Width current datetime

Fri Jun 09, 2023 2:12 am

Thanks, but is more appropriate downgrading this, also compatible with future routeros date format:
viewtopic.php?p=960070#p960070
:global setssidwithdate do={
    /system clock
    :local vdate [get date]
    :local vdoff [:toarray "0,4,5,7,8,10"]
    :local MM    [:pick $vdate ($vdoff->2) ($vdoff->3)]
    :local M     [:tonum $MM]
    :if ($vdate ~ ".../../....") do={
        :set vdoff [:toarray "7,11,1,3,4,6"]
        :set M     ([:find "xxanebarprayunulugepctovecANEBARPRAYUNULUGEPCTOVEC" [:pick $vdate ($vdoff->2) ($vdoff->3)] -1] / 2)
        :if ($M>12) do={:set M ($M - 12)}
        :set MM    [:pick (100 + $M) 1 3]
    }
    :local yyyy [:pick $vdate ($vdoff->0) ($vdoff->1)]
    :local dd   [:pick $vdate ($vdoff->4) ($vdoff->5)]
    /interface wireless set $1 ssid="$2$yyyy-$MM-$dd"
    :return "OK" 
}

:put [$setssidwithdate wlan1 "newwifi"]

Who is online

Users browsing this forum: JDF, UkRainUa and 25 guests