omit station-dump if no IBSS-interface is present

In case no interface of type IBSS is found, the array interfaces is empty, nevertheless the for-loop iterates once (with empty values) causing the system-call to iw to fail.
Check interfaces before the loop to avoid garbage-output from iw on the status-page if meshing on wifi is deactivated.
This commit is contained in:
Matthias 2016-01-13 13:13:24 +01:00
parent e012e67bf1
commit dc81fda059

View File

@ -73,20 +73,22 @@ io.write("<h2>Neighbours</h2>")
local interfaces = util.split(util.trim(util.exec("iw dev | egrep 'type IBSS|type mesh' -B 5 | grep Interface | cut -d' ' -f2"))) local interfaces = util.split(util.trim(util.exec("iw dev | egrep 'type IBSS|type mesh' -B 5 | grep Interface | cut -d' ' -f2")))
for _, ifname in ipairs(interfaces) do if interfaces ~= {} then
io.write("<h3>" .. escape_html(ifname) .. "</h3>") for _, ifname in ipairs(interfaces) do
io.write("<pre>") io.write("<h3>" .. escape_html(ifname) .. "</h3>")
io.write("<pre>")
for _, line in ipairs(util.split(util.exec("iw dev " .. ifname .. " station dump"))) do for _, line in ipairs(util.split(util.exec("iw dev " .. ifname .. " station dump"))) do
local mac = line:match("^Station (.*) %(on ") local mac = line:match("^Station (.*) %(on ")
if mac then if mac then
io.write("Station <a id=\"" .. escape_html(ifname) .. "-" .. mac .. "\">" .. mac .. "</a> (on " .. escape_html(ifname) .. ")\n") io.write("Station <a id=\"" .. escape_html(ifname) .. "-" .. mac .. "\">" .. mac .. "</a> (on " .. escape_html(ifname) .. ")\n")
else else
io.write(escape_html(line) .. "\n") io.write(escape_html(line) .. "\n")
end
end end
end
io.write("</pre>") io.write("</pre>")
end
end end
local stat, fastd_status = pcall( local stat, fastd_status = pcall(