Hi,
I want to use ping function for many IP check in one script, but how correctly to use function many times?
I did this way but error.. Resident script:53: attempt to call global 'ping' (a boolean value)
stack traceback:
Error apear when I want to use function with other IP..
Alex
I want to use ping function for many IP check in one script, but how correctly to use function many times?
I did this way but error.. Resident script:53: attempt to call global 'ping' (a boolean value)
stack traceback:
Error apear when I want to use function with other IP..
Code:
function ping(ip)
local res = os.execute('ping -c 2 -W 5 ' .. ip)
return res == 0
end
ping=ping('192.168.45.1')
if ping then
--log('Connected')
--log(ping)
grp.checkwrite('11/0/1', true)
else
log('Disconected')
grp.checkwrite('11/0/1', false)
end
ping=ping('192.168.45.2') --line 53
if ping then
--log('Connected')
--log(ping)
grp.checkwrite('11/0/2', true)
--else
--log('Disconected')
grp.checkwrite('11/0/2', false)
end
ping=ping('192.168.45.205')
if ping then
--log('Connected')
--log(ping)
grp.checkwrite('11/0/3', true)
else
--log('Disconected')
grp.checkwrite('11/0/3', false)
end
ping=ping('192.168.45.235')
if ping then
--log('Connected')
--log(ping)
grp.checkwrite('11/0/4', true)
else
--log('Disconected')
grp.checkwrite('11/0/4', false)
end
ping=ping('192.168.45.210')
if ping then
--log('Connected')
--log(ping)
grp.checkwrite('11/0/5', true)
else
--log('Disconected')
grp.checkwrite('11/0/5', false)
end
Alex