4

我正在尝试为Luci的 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 内)的值。现在我想要字符串值本身。

当我尝试这样做时:

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 中获取实际值吗?

4

1 回答 1

6

刚刚想通了,看来你必须添加以下内容:

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-17T10:58:40.010 回答