How to get the value from an option object in a section of a UCI File to write it in another file using CBI models.
With the following script it´s already possible to read the option, but it writes the names of the fields and I haven´t been able to get the values because they seem to be in a table to which I can not found how to access.
Script:
mfs = fs:option(DynamicList, "src_mac", translate("MACs con Internet"))
mfs.datatype = "macaddr"
btn = s:option(Button, "_btn", translate("ClickM2RunDScript"))
function btn.write()
local f
local v = {}
local tst
for f, v in pairs( mac ) do
arg = f
local command = "/tmp/prueba.sh " .. arg
luci.sys.call(command)
end
end
Script prueba.sh
#!/bin/ash
uci add_list firewall.@rule[9].src_mac=$1
uci commit firewall
service firewall restart
Result:
list src_mac 'tag_error'
list src_mac 'vallist'
list src_mac 'tag_missing'
list src_mac 'cast'
list src_mac 'section'
list src_mac 'deps'
list src_mac 'children'
list src_mac 'track_missing'
list src_mac 'optional'
list src_mac 'template'
list src_mac 'option'
list src_mac 'datatype'
list src_mac 'tag_invalid'
list src_mac 'config'
list src_mac 'title'
list src_mac 'rmempty'
list src_mac 'keylist'
list src_mac 'map'
list src_mac 'description'
list src_mac 'tag_reqerror'
Thanks a lot for your help. Let me know if you have any questions or more info iss needed.