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 に答える