1 -- Licensed to the public under the GNU General Public License v2.
3 module("luci.controller.commands", package.seeall)
5 sys = require "luci.sys"
6 ut = require "luci.util"
12 entry({"admin", "config", "command"},
13 call("execute")).dependent = false
17 return s:match("^%s*(.-)%s*$")
20 function split_and_trim(str, sep)
22 local reg = string.format("([^%s]+)", sep)
23 for item in string.gmatch(str, reg) do
24 item_trimed = trim(item)
25 if string.len(item_trimed) > 0 then
26 table.insert(array, item_trimed)
33 local commands = luci.http.formvalue("command")
34 io.stderr:write("Execute command: %s\n" % commands)
36 local command_array = split_and_trim(commands, ";")
37 for index, command in ipairs(command_array) do
41 luci.http.prepare_content("application/json")
42 luci.http.write_json("{'status':'ok'}")