Community discussions

MikroTik App
 
User avatar
AYcoo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Thu May 19, 2016 8:44 pm

help for this script

Fri Jan 19, 2024 9:44 am

it was working on v6 no problems i upgraded to v7.13 now it doesn't work

:local date1 "jan/28/2024";

:local date2 [ /system clock get value-name=date ];

:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");

:local date1month [ :pick $date1 0 3 ];
:local date1day [ :pick $date1 4 6 ];
:local date1year [ :pick $date1 7 11 ];
:local mm ([ :find $months $date1month -1 ] + 1);
:if ($mm < 10) do={
	:set date1month ("0" . $mm);
} else={:set date1month $mm;
}
:local date1value ($date1year . $date1month . $date1day);



:local date2month [ :pick $date2 0 3 ];
:local date2day [ :pick $date2 4 6 ];
:local date2year [ :pick $date2 7 11 ];
:local mm ([ :find $months $date2month -1 ] + 1);
:if ($mm < 10) do={
    :set date2month ("0" . $mm);
} else={
    :set date2month $mm;
}

:local date2value ($date2year . $date2month . $date2day);
if ($date2value >= $date1value) do={
	/ip hotspot ip-binding {
:local ui 10.0.0.218
:local uiList [find address=$ui]
:foreach uii in=$uiList do={
set $uii disabled=yes 
}
:log error "CL17 has been Disabled"
}}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12024
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: help for this script

Fri Jan 19, 2024 9:56 am

 
User avatar
AYcoo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Thu May 19, 2016 8:44 pm

Re: help for this script

Fri Jan 19, 2024 10:01 am

ty for replying so ineed to downgrade to 7.8 or 7.9 for it to get it work
 
User avatar
AYcoo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Thu May 19, 2016 8:44 pm

Re: help for this script

Fri Jan 19, 2024 12:44 pm

still get same result after downgrading to 7.9.2 !!
:local date1 "feb/18/2024";

:local date2 [ /system clock get value-name=date ];

:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep
","oct","nov","dec");

:local date1month [ :pick $date1 0 3 ];
:local date1day [ :pick $date1 4 6 ];
:local date1year [ :pick $date1 7 11 ];
:local mm ([ :find $months $date1month -1 ] + 1);
:if ($mm < 10) do={
{... :set date1month ("0" . $mm);
syntax error (line 2 column 6)
} else={:set date1month $mm;
}
:local date1value ($date1year . $date1month . $date1day);



:local date2month [ :pick $date2 0 3 ];
:local date2day [ :pick $date2 4 6 ];
:local date2year [ :pick $date2 7 11 ];
:local mm ([ :find $months $date2month -1 ] + 1);
:if ($mm < 10) do={
{...     :set date2month ("0" . $mm);
syntax error (line 2 column 10)
} else={
    :set date2month $mm;
syntax error (line 1 column 10)
}

:local date2value ($date2year . $date2month . $date2day);
if ($date2value >= $date1value) do={
{... /ip hotspot ip-binding {
{{... :local ui 10.0.0.95
{{... :local uiList [find address=$ui]
{{... :foreach uii in=$uiList do={
{{{... set $uii disabled=yes 
{{{... }
{{... :log error "CL67 has been Disabled"
{{... }}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12024
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: help for this script

Fri Jan 19, 2024 12:50 pm

If you want test the script on terminal, you must put all the script between { }
else each line is treated as single script, and you give errors.
And when you paste terminal output, do not use "code", is not one scipt, and do not remove prompt...

terminal output code

[rex@do-not-remove-prompt] > :local date1 "jan/28/2024";
[rex@do-not-remove-prompt] > 
[rex@do-not-remove-prompt] > :local date2 [ /system clock get value-name=date ];
[rex@do-not-remove-prompt] > 
[rex@do-not-remove-prompt] > :local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
[rex@do-not-remove-prompt] > 
[rex@do-not-remove-prompt] > :local date1month [ :pick $date1 0 3 ];
[rex@do-not-remove-prompt] > :local date1day [ :pick $date1 4 6 ];
[rex@do-not-remove-prompt] > :local date1year [ :pick $date1 7 11 ];
[rex@do-not-remove-prompt] > :local mm ([ :find $months $date1month -1 ] + 1);
[rex@do-not-remove-prompt] > :if ($mm < 10) do={
{... :set date1month ("0" . $mm);              
syntax error (line 2 column 6) variable date1mont undefined
[rex@do-not-remove-prompt] > } else={:set date1month $mm;
[rex@do-not-remove-prompt] > }
[rex@do-not-remove-prompt] > :local date1value ($date1year . $date1month . $date1day);
[rex@do-not-remove-prompt] > 
[rex@do-not-remove-prompt] > 
[rex@do-not-remove-prompt] > 
[rex@do-not-remove-prompt] > :local date2month [ :pick $date2 0 3 ];
[rex@do-not-remove-prompt] > :local date2day [ :pick $date2 4 6 ];
[rex@do-not-remove-prompt] > :local date2year [ :pick $date2 7 11 ];
[rex@do-not-remove-prompt] > :local mm ([ :find $months $date2month -1 ] + 1);
[rex@do-not-remove-prompt] > :if ($mm < 10) do={
{...     :set date2month ("0" . $mm);          
syntax error (line 2 column 10) variable date2month undefined
[rex@do-not-remove-prompt] > } else={
[rex@do-not-remove-prompt] >     :set date2month $mm;
syntax error (line 1 column 10) variable date2month undefined
[rex@do-not-remove-prompt] > }
[rex@do-not-remove-prompt] > 
[rex@do-not-remove-prompt] > :local date2value ($date2year . $date2month . $date2day);
[rex@do-not-remove-prompt] > if ($date2value >= $date1value) do={
{... /ip hotspot ip-binding {                                   
syntax error (line 2 column 24) package hotspot not found
[rex@do-not-remove-prompt] > :local ui 10.0.0.218
[rex@do-not-remove-prompt] > :local uiList [find address=$ui]
expected end of command (line 1 column 28) parameter addres unexpected on root :find
[rex@do-not-remove-prompt] > :foreach uii in=$uiList do={
{... set $uii disabled=yes                              
expected end of command (line 2 column 18) parameter disabled unexpected on root :set
[rex@do-not-remove-prompt] > }
[rex@do-not-remove-prompt] > :log error "CL17 has been Disabled"
[rex@do-not-remove-prompt] > }}
 
User avatar
AYcoo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Thu May 19, 2016 8:44 pm

Re: help for this script

Fri Jan 19, 2024 1:13 pm

so there is no fixing for the script on v7.13
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12024
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: help for this script

Fri Jan 19, 2024 1:13 pm

Someone must rewrite the script, near from scratch.
Last edited by rextended on Fri Jan 19, 2024 1:22 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12024
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: help for this script

Fri Jan 19, 2024 1:20 pm

Or probably the script is useless, given how it is written and from the little we understand what it is for,
just program this line below every 28th of the month at 23:59...
/ip hotspot ip-binding set [find where address=10.0.0.95] disabled=yes ; :log error "CL67 has been Disabled"
Last edited by rextended on Fri Jan 19, 2024 1:31 pm, edited 4 times in total.
 
User avatar
AYcoo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Thu May 19, 2016 8:44 pm

Re: help for this script

Fri Jan 19, 2024 1:21 pm

so there is no fixing for the script on v7.13
Someone must rewrite the script, near from scratch.
can you help with that please
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12024
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: help for this script

Fri Jan 19, 2024 1:22 pm

Read previous post
 
User avatar
AYcoo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Thu May 19, 2016 8:44 pm

Re: help for this script

Fri Jan 19, 2024 1:24 pm

im using this script with app so it must do this and check for the date if user still on subscription date or not if no it disabled
Last edited by AYcoo on Fri Jan 19, 2024 1:27 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12024
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: help for this script

Fri Jan 19, 2024 1:25 pm

Do you have a script for each user, and in each one you change the date, name and IP??
Last edited by rextended on Fri Jan 19, 2024 1:32 pm, edited 2 times in total.
 
User avatar
AYcoo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Thu May 19, 2016 8:44 pm

Re: help for this script

Fri Jan 19, 2024 1:29 pm

Please remove quote on previous post.

Do you have a script for each user, and in each one you change the date, name and IP??
yes on scheduler it check every day if user subscription still valid or not
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12024
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: help for this script

Fri Jan 19, 2024 1:32 pm

Write a detailed description, and maybe some volunteer will rewrite it for you.
But until it is perfectly clear how it is used, and where it is written,
based only on what you have written so far, the logical conclusion is what I wrote on previous post...

Instead of modify everytime the date inside the script, change the date of the scheduler when the line must run...
Last edited by rextended on Fri Jan 19, 2024 1:33 pm, edited 1 time in total.
 
User avatar
AYcoo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Thu May 19, 2016 8:44 pm

Re: help for this script

Fri Jan 19, 2024 1:33 pm

k ty for now

Who is online

Users browsing this forum: Bing [Bot] and 7 guests