"print where" indices relative, not absolute

I’m posting this issue to the general list as it will affect users at the Terminal CLI, via SSH and Scripting.

In v5.12, don’t know about other variants, issuing a command including “print where xxx=xxx” to return a specific entry or a subset of entries, the index numbers returned are relative to the search, i.e. base of 0, and have no correlation whatsoever to that entry’s absolute index in a full listing. So extracting the index from a partial listing and performing some action is highly likely to affect the wrong record.

I don’t know if this is a bug or considered normal behaviour, either way it could catch out the unwary.

I’m trying to programmatically reset specific OpenVPN connections on over 200 routers using a Perl Expect script over SSH to disable, sleep, then enable. (Note: the connection being reset is NOT the one I’m communicating over). However, I cannot do this with “print where” and I can’t do ‘disable where connect-to=xxx’ or ‘enable where connect-to=xxx’.

Anyone got any idea how to do this without getting a complete list and parsing the entire output for the index I want?

There seems to be an option ‘print as-value’, but can’t find any documentation on this and it doesn’t seem to so anything.

Any help would be appreciated.

OK, found info on ‘print as-value’. Doing

:put [/int ovpn-client print as-value]

works, but

/int ovpn-client print as-value

doesn’t.

A bit bizarre as all other print options work without :put and doing print ? on the CLI seems to imply you should be able to get a valid response.

So this now returns a ‘;’ delimited list containing ‘.id=’ entries, e.g. ‘.id=*8’, which strangely although bearing no relation to indices listed either on the CLI or in WinBox, does actually work!

So the following now returns an absolute index on which to perform actions:-

:put [/int ovpn-client print as-value where connect-to=xxx]

So you can do:-

/int ovpn-client disable *8

Somewhat counter intuitive, in most programming languages this would equate to disabling all interfaces where the last digit of the interface id = 8.