如何在3.2版本的API中使用find命令
操作如下:用API客户端连接服务器后,输入
/ip/hotspot/user/find
则返回所有的用户ID。
我想实现如 find name=chen的功能,却实现不了,总告诉我语法错误。
另 虽然可以通过
/ip/hotspot/user/get
=.id=chen
的形式得到用户名为chen的资料,但此法会在系统中不存在chen用户的情况下报出异常ERROR: invalid item number,而不是find的空结果。
请高人指点,如何在API中使用find命令。 3.21以后版本增加了查询命令
Queries print command accepts query words that limit set of returned items. This feature appeared in the 3.21 version.
Query words begin with '?'.
Order of query words is significant. Query is evaluated starting from the first word.
Query is evaluated for each item in the list. If query succeeds, item is processed, if query fails, item is ignored.
Query is evaluated using a stack of boolean values. Initially stack contains infinite amount of 'true' values. At the end of evaluation, if stack contains at least one 'false' value, query fails.
Query words operate according to the following rules:
?namepushes 'true' if item has value of property name, 'false' if it does not.
?-namepushes 'true' if item does not have value of property name, 'false' otherwise.
?name=x
?=name=xpushes 'true' if property name has value equal to x, 'false' otherwise.
?<name=xpushes 'true' if property name has value less than x, 'false' otherwise.
?>name=xpushes 'true' if property name has value greater than x, 'false' otherwise.
?#operationsapplies operations to the values in the stack.
operation string is evaluated left to right.
sequence of decimal digits followed by any other character or end of word is interpreted as a stack index. top value has index 0.
index that is followed by a character pushes copy of value at that index.
index that is followed by the end of word replaces all values with the value at that index.
! character replaces top value with the opposite.
& pops two values and pushes result of logical 'and' operation.
| pops two values and pushes result of logical 'or' operation.
. after an index does nothing.
. after another character pushes copy of top value.
Examples:
Get all ethernet and VLAN interfaces:
/interface/print
?type=ether
?type=vlan
?#|
Get all routes that have non-empty comment:
/ip/route/print
?>comment= 很遗憾,我用的是3.20版的,能告诉我如果在API中使用FIND命令吗? 自己顶自己 在自己的程序中把异常ERROR处理掉就OK了
页:
[1]