V7.8
I have a script:
/ip dhcp-server {
:local poolname;
:local counter;
:local servername;
:set counter [/ip/dhcp-server/ print count-only] ;
:log info ("Total DHCP Servers: " . $counter);
:set counter ($counter - 1);
#:set counter 5;
:while ($counter) do={
:log info ("Counter: " . $counter);
:set servername [/ip/dhcp-server/ get $counter name];
:log info ("Get: " . $servername);
:set counter ($counter - 1);
:log info ("Done");
}
}
Basically gets total number of DHCP servers then logs the name. I have a total of 6 servers configured, therefore it's 0-5. I can remove the while loop and set counter manually. If I use value 5 for counter the script stops at :set servername [/ip/dhcp-server/ get $counter name]; I get results using counter value of 0-4.
This behavior only happens when I click the Test button or when run via Schedule, it works fine if run from CLI.
I have a script:
/ip dhcp-server {
:local poolname;
:local counter;
:local servername;
:set counter [/ip/dhcp-server/ print count-only] ;
:log info ("Total DHCP Servers: " . $counter);
:set counter ($counter - 1);
#:set counter 5;
:while ($counter) do={
:log info ("Counter: " . $counter);
:set servername [/ip/dhcp-server/ get $counter name];
:log info ("Get: " . $servername);
:set counter ($counter - 1);
:log info ("Done");
}
}
Basically gets total number of DHCP servers then logs the name. I have a total of 6 servers configured, therefore it's 0-5. I can remove the while loop and set counter manually. If I use value 5 for counter the script stops at :set servername [/ip/dhcp-server/ get $counter name]; I get results using counter value of 0-4.
This behavior only happens when I click the Test button or when run via Schedule, it works fine if run from CLI.
Statistics: Posted by lanhampr — Mon Dec 11, 2023 11:09 pm