local uci = require("luci.model.uci").cursor() local p = uci:get("network", "lan", "ipaddr") print(p)
get_all
1 2 3 4
local LuciUtil = require("luci.util") local uci = require("luci.model.uci").cursor() local p = uci:get_all("network", "lan") LuciUtil.dumptable(p)
get_list
sample cat /etc/config/network:
1 2 3 4 5 6 7
config interface 'wan' option proto 'static' option ipaddr '10.1.1.2' option netmask '255.255.255.0' option gateway '10.1.1.1' list dns '2.2.2.2' list dns '1.1.1.1'
codes:
1 2 3 4
local uci = require("luci.model.uci").cursor() local LuciUtil = require("luci.util") local p = uci:get_list("network", "wan", "dns") LuciUtil.dumptable(p)
function test() local uci = require("luci.model.uci").cursor() uci:set_confdir("/tmp/etc/config") -- set_confdir之后,此uci都会去操作/tmp/etc/config目录 -- 作用域为本函数内 end
set_list
1 2 3 4 5 6 7 8 9 10 11
local uci = require("luci.model.uci").cursor() local tbl = { [1] = "3.3.3.3", [2] = "4.4.4.4" }