Strange problem.
I have dhcp-client:
[admin@MikroTik] > /ip dhcp-client print
Flags: X - disabled, I - invalid, D - dynamic
INTERFACE USE-PEER-DNS ADD-DEFAULT-ROUTE STATUS ADDRESS
0 bridge-inet yes yes bound XXX.XXX.XXX.XXX/BB
But can't get any values by console:
[admin@MikroTik] > /ip dhcp-client get 0 address
[admin@MikroTik] > /ip dhcp-client get 0 default-route-distance
NO values listed...
If I try to use scripting everything ok:
[admin@MikroTik] > :foreach i in=[/ip dhcp-client find] do={ :put [/ip dhcp-client get $i default-route-distance];}
1
Index numbers (you’re using 0 in your example) are dynamic and are created when running print command. They are only valid until next print (the worst thing would be that add or remove or similar doesn’t invalidate them). Which means you can’t reference entries like this from scripts, you have to use find in similar manner you’re doing in the working example … you can narrow down the result list by using find where …