Reputation: 6968
I am trying to build a web interface for an OpenWRT module for Luci. I have the following code:
m = Map("amld_cbi", translate ("amld_status"))
s = m:section(TypedSection, "amld_conf","Status")
fqdn = s:option(DummyValue, "fqdn", "FQDN value")
This works fine for displaying the value of fqdn (which is located inside amld_cbi) on the screen. Now I want the String value itself.
When I try to do:
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)
I get the following error:
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>
Does anybody know how to get the actual value from the variable fqdn?
Upvotes: 4
Views: 3484
Reputation: 6968
Just figured it out, looks like you have to add the following:
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 **
Where my amld_cbi file looks like this:
config amld_conf 'amld'
option fqdn 'www.google.com'
Upvotes: 6