Hello. Looking for a way to give the “dhcphosts” variable the value, as num, with actual dynamic dhcp clients number on the system, so I can do something like: (if dhcphosts != 0, do something).
“dhcphosts” stores the value as an array as follows, any idea on how to achieve this?. I need to go from being an array to a number for the variable.
on that way you write a function to count everityme launched the number of dynamic leases
With your method (except for the detail of useless print the number on the terminal) you were almost close to the solution for write directly the value inside a variable:
:global dhcphosts [/ip dhcp-server lease print count-only where dynamic=yes]
and about:
:typeof [$dhcphosts ]
when you call a variable, do not use the !
any results on terminal must be see with :put
you must write like
:put $dhcphosts
:put [:typeof $dhcphosts]