11.08.2020, 11:46
Hi there
For the past two hours I've been trying to declare a variable that would count how many times the LogiMachine has not reached the Internet.
If I don't declare the variable PingFailure, I get to following error message:
Resident script:17: attempt to perform arithmetic on local 'PingFailure' (a nil value)
If I do declare it, it never counts above 1 as it resets itself each time I carry out the script. How is this done, I've searched this forum and the Internet?
function ping(ip)
local res = os.execute('ping -c 2 -W 5 ' .. ip)
return res == 0
end
local PingFailure = 0
ping = ping('google.com')
if ping then
log('INTERNET connected')
log(ping)
else
log('INTERNET disconnected')
log(ping)
PingFailure = PingFailure + 1
end
log(PingFailure)
I look forward to hearing from you.
Cheers!
Martin
For the past two hours I've been trying to declare a variable that would count how many times the LogiMachine has not reached the Internet.
If I don't declare the variable PingFailure, I get to following error message:
Resident script:17: attempt to perform arithmetic on local 'PingFailure' (a nil value)
If I do declare it, it never counts above 1 as it resets itself each time I carry out the script. How is this done, I've searched this forum and the Internet?
function ping(ip)
local res = os.execute('ping -c 2 -W 5 ' .. ip)
return res == 0
end
local PingFailure = 0
ping = ping('google.com')
if ping then
log('INTERNET connected')
log(ping)
else
log('INTERNET disconnected')
log(ping)
PingFailure = PingFailure + 1
end
log(PingFailure)
I look forward to hearing from you.
Cheers!
Martin