From ff5cdc30193ba69944f6772f213e63ea00678861 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Aug 2020 09:23:56 +0200 Subject: [ ... print count-only ...] -> [ :len [ ... find ... ] ] Using 'print count-only' always prints a number to terminal, even if the value is evaluated in a condition or assigned to a variable. This can be quite annoying. Behavior will not chance (SUP-25503), so replacing the code... --- dhcp-to-dns | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dhcp-to-dns') diff --git a/dhcp-to-dns b/dhcp-to-dns index 4e2c7f2..3a95eb6 100644 --- a/dhcp-to-dns +++ b/dhcp-to-dns @@ -22,7 +22,7 @@ :local Ttl 5m; :local CommentPrefix "managed by dhcp-to-dns for "; -:if ([ / ip dns static print count-only where comment="--- dhcp-to-dns above ---" name=- type=NXDOMAIN disabled ] = 0) do={ +:if ([ :len [ / ip dns static find where comment="--- dhcp-to-dns above ---" name=- type=NXDOMAIN disabled ] ] = 0) do={ / ip dns static add comment="--- dhcp-to-dns above ---" name=- type=NXDOMAIN disabled=yes; $LogPrintExit warning "Added disabled static dns record with comment '--- dhcp-to-dns above ---'." false; } @@ -31,7 +31,7 @@ :foreach DnsRecord in=[ / ip dns static find where comment ~ $CommentPrefix ] do={ :local DnsRecordVal [ / ip dns static get $DnsRecord ]; :local MacAddress [ $CharacterReplace ($DnsRecordVal->"comment") $CommentPrefix "" ]; - :if ([ / ip dhcp-server lease print count-only where mac-address=$MacAddress address=($DnsRecordVal->"address") dynamic=yes status=bound ] > 0) do={ + :if ([ :len [ / ip dhcp-server lease find where mac-address=$MacAddress address=($DnsRecordVal->"address") dynamic=yes status=bound ] ] > 0) do={ $LogPrintExit debug ("Lease for " . $MacAddress . " (" . $DnsRecordVal->"name" . ") still exists. Not deleting DNS entry.") false; } else={ :local Found false; -- cgit v1.2.3-54-g00ecf