My script stops on entry in dhcp who are not exist.
I try check if in dhcp leases exist IP address and have a host-name and get it if possible.
ip dhcp-server lease get [find address=10.5.10.51] host-name
no such item
put [ip dhcp-server lease find address=10.5.10.51 ]
put [:typeof [ip dhcp-server lease find address=10.5.10.51 ]]
array
put [typeof [ip dhcp-server lease get [find address=10.5.20.1] host-name ]]
no such item
entry who exist but not have hostname
put [typeof [ip dhcp-server lease get [find address=10.5.20.2] host-name ]]
nil
proper entry
put [typeof [ip dhcp-server lease get [find address=10.5.20.3] host-name ]]
str
len – return number of elements in value
When element not exist then len=0, when exist len=1
put [len [ip dhcp-server lease find address=10.5.20.1 ]]
0
put [len [ip dhcp-server lease find address=10.5.20.2 ]]
1
put [len [ip dhcp-server lease find address=10.5.20.3 ]]
1