Community discussions

MikroTik App
 
eles
just joined
Topic Author
Posts: 14
Joined: Tue Jun 18, 2013 6:20 pm

dhcp-server lease lease-time can't be used in scripts?

Fri Nov 12, 2021 7:16 pm

Hi,
I have a simple script in dhcp-server :
ip dhcp-server lease set lease-time=00:10:00 [find where dynamic =no]
(the default 'dynamic' lease time is 14 days, this is to make certain tasks easier, but when it's set static, it's 'known' and 'on the record', and the lease-time can then be changed to more 'realistic' value).

But, this creates a lot of 'dhcp lease changed' messages in log (with topic system, info, so kinda hard to filter without nuking the entire log stream)

Unfortunately, simple
 [find where dynamic=no and lease-time !=10m] 
doesn't work... (also tried 00:10:00 and 0d 00:10:00, same result...)
(doesn't work = does not change anything or just continues as if the lease-time comparison wasn't there at all)

To that end i tried the following commands on terminal, with zero results given, or errors returned:
> ip dhcp-server lease find where lease-time ~10m
> ip dhcp-server lease find where lease-time ~00:10:00
> ip dhcp-server lease find where lease-time =:totime 10m
> ip dhcp-server lease find where lease-time =:totime 00:10:00
> ip dhcp-server lease find where "lease-time" =:totime 00:10:00
> ip dhcp-server lease find where "lease-time" = 00:10:00  
> ip dhcp-server lease find where "lease-time" =10m      
> ip dhcp-server lease find where (lease-time) =10m  
> ip dhcp-server lease get value-name=lease-time [find where dynamic =no]
invalid internal item number
> ip dhcp-server lease get value=lease-time [find where dynamic =no]     
invalid internal item number
> ip dhcp-server lease get lease-time [find where dynamic =no]      
syntax error (line 1 column 26)
Can lease-time be even used as a test argument in any script? It can be read (via print or gui) but why script treats it as write-only value?

Thanks in advance
Hope it makes sense.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: dhcp-server lease lease-time can't be used in scripts?  [SOLVED]

Fri Nov 12, 2021 7:34 pm

you forget everytime to not put extra space

x=1 rigt
x =1, x= 1 or x = 1 wrong
:put [/ip dhcp-server lease find where dynamic=no and lease-time=1h]
:put [/ip dhcp-server lease find where dynamic=no and lease-time=60m]
:put [/ip dhcp-server lease find where dynamic=no and lease-time=01:00:00]

:put [/ip dhcp-server lease find where dynamic=no and lease-time!=1h]
:put [/ip dhcp-server lease find where dynamic=no and lease-time!=60m]
:put [/ip dhcp-server lease find where dynamic=no and lease-time!=01:00:00]

ip dhcp-server lease set lease-time=00:10:00 [find where dynamic =no]
-->>
/ip dhcp-server lease set [find where dynamic=no and lease-time!=00:10:00] lease-time=00:10:00

# or more clear

/ip dhcp-server lease set [find where dynamic=no and lease-time!=10m] lease-time=10m
 
eles
just joined
Topic Author
Posts: 14
Joined: Tue Jun 18, 2013 6:20 pm

Re: dhcp-server lease lease-time can't be used in scripts?

Mon Nov 15, 2021 8:30 am

you forget everytime to not put extra space

x=1 rigt
x =1, x= 1 or x = 1 wrong

[...snip...]

/ip dhcp-server lease set [find where dynamic=no and lease-time!=10m] lease-time=10m
Thank you!....
So simple...
:)

Who is online

Users browsing this forum: No registered users and 21 guests