[luci] Getting UCI configuration data
Matt Redfearn
matt.redfearn at nxp.com
Tue Jul 19 10:36:52 CEST 2011
Thanks Jow, that works perfectly now :-)
How come the "system" section is anonymous? If the first parameter relates to the config file, second to the section in the file and third the variable, where does the anonymity come from?
Is it because you could have multiple "system" sections in the "system" config file?
Thanks,
Matt
-----Original Message-----
From: luci-bounces at lists.subsignal.org [mailto:luci-bounces at lists.subsignal.org] On Behalf Of Jo-Philipp Wich
Sent: 15 July 2011 17:00
To: luci at lists.subsignal.org
Subject: Re: [luci] Getting UCI configuration data
Hi Matt,
your approach is fine, you just overlooked the fact that the "system"
section is anonymous so you cannot reference it by name.
The correct way would be:
local hostname
luci.model.uci.cursor():foreach("system", "system",
function(s) hostname = s.hostname end)
print(hostname)
Since this is often needed, we added a shortcut doing exactly that:
local hostname = luci.model.uci.cursor():get_first("system", "system", "hostname")
print(hostname)
See also http://luci.subsignal.org/api/luci/modules/luci.model.uci.html#Cursor.get_first
Also not that it must be <%= expression %> instead of <% expression %>
if you want the result to be written onto the page.
Regards,
Jow
_______________________________________________
luci mailing list
luci at lists.subsignal.org
https://lists.subsignal.org/mailman/listinfo/luci
More information about the luci
mailing list