gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 01:30:38 24 4
gpt4 key购买 nike

我正在尝试为 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 中获取实际值吗?

最佳答案

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

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'

关于lua - 从配置文件中获取字符串值 - LuCI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19422970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com