This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

MikroTik API Lua library
#16
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
Reply


Messages In This Thread
MikroTik API Lua library - by admin - 20.10.2020, 06:57
RE: MikroTik API Lua library - by FatMax - 20.10.2020, 11:48
RE: MikroTik API Lua library - by admin - 20.10.2020, 12:13
RE: MikroTik API Lua library - by DGrandes - 03.12.2020, 17:45
RE: MikroTik API Lua library - by admin - 04.12.2020, 07:35
RE: MikroTik API Lua library - by DGrandes - 07.12.2020, 13:11
RE: MikroTik API Lua library - by admin - 07.12.2020, 13:49
RE: MikroTik API Lua library - by DGrandes - 07.12.2020, 15:03
RE: MikroTik API Lua library - by admin - 09.12.2020, 07:19
RE: MikroTik API Lua library - by DGrandes - 09.12.2020, 08:09
RE: MikroTik API Lua library - by FatMax - 07.01.2021, 23:20
RE: MikroTik API Lua library - by Igori - 10.01.2021, 15:45
RE: MikroTik API Lua library - by admin - 11.01.2021, 08:07
RE: MikroTik API Lua library - by Igori - 11.01.2021, 19:50
RE: MikroTik API Lua library - by edgars - 26.08.2021, 08:28

Forum Jump: