从配置文件中获取字符串值 - LuCI

我正在尝试为[Luci](http://luci.subsignal.org/trac)的OpenWRT模块构建Web界面。 我有以下代码:

m = Map("amld_cbi", translate ("amld_status"))
s = m:section(TypedSection, "amld_conf","Status")
fqdn = s:option(DummyValue, "fqdn", "FQDN value")

这对于在屏幕上显示fqdn的值(位于amld \ _cbi内部)很好用。 现在我想要String值本身。

当我尝试执行:

m = Map("amld_cbi", translate ("amld_status"))
s = m:section(TypedSection, "amld_conf","Status")
fqdn = s:option(DummyValue, "fqdn", "FQDN value")

luci.sys.call("amld " .. fqdn)

我得到以下错误:

The called action terminated with an exception:
/usr/lib/lua/luci/model/cbi/amld/amld_status.lua:25: attempt to concatenate global 'fqdn' (a table value)
stack traceback:
    [C]: in function 'assert'
    /usr/lib/lua/luci/dispatcher.lua:448: in function 'dispatch'
    /usr/lib/lua/luci/dispatcher.lua:195: in function </usr/lib/lua/luci/dispatcher.lua:194>

有人知道如何从变量fqdn中获取实际值吗?

点赞
用户985012
用户985012

刚刚搞清楚,看起来你需要添加以下内容:

m = Map("amld_cbi", translate ("amld_status"))
s = m:section(TypedSection, "amld_conf","Status")
fqdn = s:option(DummyValue, "fqdn", "FQDN value")

fqdn_string = uci.get("amld_cbi", "amld", "fqdn")

luci.sys.call("amld " .. tostring(fqdn_string)) **the tostring function may not be necessary **

我的amld_cbi文件看起来像这样:

config amld_conf 'amld'
    option fqdn 'www.google.com'
2013-10-17 10:58:40