26.08.2021, 08:28
Example: how to disable list of Mikrotik access points (managed by capsman) with the comment "ap"
Code:
mt, err = require('user.mikrotik').new('192.168.0.11') -- capsman manager IP 192.168.0.11
if mt then
res, err = mt:login('api', 'Password123') -- user api, password Password123
if res then
list, err = mt:readlist('/caps-man/interface/print')
for _, item in ipairs(list) do
id = item['.id']
if id and item.comment == 'ap' then
r1, e1 = mt:send('/caps-man/interface/disable', '=.id=' .. id)
r2, e2 = mt:read()
-- log(id, r1, e1, r2, e2)
end
end
else
log('login failed', tostring(err))
end
mt:close()
else
log('connect failed', tostring(err))
end