Closed jeanpablojp closed 10 years ago
What happens? Does it simply do nothing, or does it generate an error?
I've looked this up, and unfortunately you won't be able to use the 'find' command from the API. This not a restriction of my library, but of the underlying RouterOS API.
On this page http://wiki.mikrotik.com/wiki/API_command_notes they simply say:
Note: Find command have many constructs that are part of scripting, thus not available through API
You should however be able to delete the users by retrieving their information and issuing a delete command for the user's unique .id or name, or by just deleting them by name.
Example that should work:
con.execute("/ip/hotspot/user/remove .id=joe")
Example that will work:
Example:
List<Map<String, String>> res = con.execute("/ip/hotspot/active/print where name=teste");
for (Map<String, String> attr : res) {
String id = attr.get(".id");
con.execute("/ip/hotspot/active/remove .id=" + id);
}
}
Issue closed. Not a bug, but design feature of underlying API.
I am little confused here. To me neither of this is working: Example that should work:
con.execute("/ip/hotspot/user/remove .id=joe")
Example that will work:
Example:
List<Map<String, String>> res = con.execute("/ip/hotspot/active/print where name=teste");
for (Map<String, String> attr : res) {
String id = attr.get(".id");
con.execute("/ip/hotspot/active/remove .id=" + id);
}
}
I found what my problem was instead of "/ip/hotspot/active/print where name=teste", you must have "/ip/hotspot/active/print where user=teste" Thanks!
I'm trying to remove active users from hotspot but its not working. I've tried this commands:
(I need to remove all the active users from hotspot where the field user="teste")
This works on mikrotik: /ip hotspot active remove [find user="teste"]
Using the API i've tried: /ip/hotspot/active/remove [find user='teste'] /ip/hotspot/active/remove user='teste' /ip/hotspot/active/remove [find user=\"teste\"] /ip/hotspot/active/remove user=\"teste\"
There is a bug or limitation here or i'm doing something wrong here???
Thanks in advance.