Community discussions

MikroTik App
 
jandervga
just joined
Topic Author
Posts: 2
Joined: Wed Feb 14, 2024 8:51 pm

Script breaks on ROS 7 due to changes in date format

Wed Feb 14, 2024 8:57 pm

Can you help me? I have this script that changes the user's password on the hotspot, but in the new version it no longer works due to the date format change.
Anyone who can help me, thank you

:local senha;
:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
:local ds [/system clock get date]

:local month [ :pick $ds 0 3 ];
:local mm ([ :find $months $month -1 ] + 1);
:if ($mm < 10) do={ :set $mm ("0" . $mm); }

:set  senha ( "user*" . $mm * [:pick $ds 4 6])

/ip hotspot user set "user" password=$senha
Last edited by tangent on Wed Feb 14, 2024 9:10 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script breaks on ROS 7 due to changes in date format

Wed Feb 14, 2024 10:06 pm

 
User avatar
karlisi
Member
Member
Posts: 443
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: Script breaks on ROS 7 due to changes in date format

Thu Feb 15, 2024 8:42 am

Or in short:
:local senha;
:local ds [/system clock get date]
:local mm [:pick $date 5 7];

:set  senha ( "user*" . $mm * [:pick $ds 8 10])

/ip hotspot user set "user" password=$senha
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script breaks on ROS 7 due to changes in date format

Thu Feb 15, 2024 10:24 am

Or without errors:

RouterOS 7.10+ code

{
:local ds    [/system clock get date]
:local mm    [:tonum [:pick $ds 5  7]]
:local dd    [:tonum [:pick $ds 8 10]]
:local senha "user*$($mm * $dd)"
/ip hotspot user set "user" password=$senha
}
 
jandervga
just joined
Topic Author
Posts: 2
Joined: Wed Feb 14, 2024 8:51 pm

Re: Script breaks on ROS 7 due to changes in date format

Thu Feb 15, 2024 2:50 pm

It worked, thank you very much
Last edited by BartoszP on Thu Feb 15, 2024 3:46 pm, edited 1 time in total.
Reason: No need to quote whole code to comment it

Who is online

Users browsing this forum: No registered users and 3 guests