如何捕获更改的配置文件中的值

时间:2017-11-26 10:46:26

标签: regex lua config openwrt luci

我已经在配置文件中捕获了这样的值:

file = io.open("testch", "r") -- testch is config file in same directory
file:read("*l")

file:seek("cur", 17)
version = file:read("*l")
_, _, version = string.find(version, "(%d+.%d+)'")

file:seek("cur", 19)
serialnum = file:read("*l")
_, _, serialnum = string.find(serialnum, "(%d+)'")

file:seek("cur", 15)
power = file:read("*l")
_, _, power = string.find(power, "(%d+)'")

io.close(file)

/* below code is config file in the same directory with upper one */
config test
       option version '1.0'
       option serialnum '1234567890'
       option power '30'

但是,当我单击Luci中的Save& Apply按钮更改配置文件中的值时,更改的数组将转到下面。

那是我的问题。当配置文件的数组顺序发生变化时,我的解决方案在这种情况下无法应用。 (我的解决方案可以在固定的情况下应用。)

是否有适用于所有情况的解决方案(配置文件' s数组已更改的情况)?

0 个答案:

没有答案