如何从 f 中读取数值结果:close ()

how to read a numerical result from f: close ()

我是一个糟糕的初学者:

f = io.popen("ping -c 2 -t 5 192.168.0.1")
l = f:read("*a")
f:close()       
if f==0 then print ("active")
else print ("off")
end

local f = io.popen("ping -c 2 -t 5 192.168.0.1")
local l = f:read("*a")
f = f:close()
if f then print ("active") else print ("off") end