This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Ping IP doesn't work
#7
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..

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
Reply


Messages In This Thread
Ping IP doesn't work - by MantasJ - 08.08.2019, 07:30
RE: Ping IP doesn't work - by Daniel - 08.08.2019, 07:49
RE: Ping IP doesn't work - by admin - 08.08.2019, 07:49
RE: Ping IP doesn't work - by MantasJ - 08.08.2019, 08:10
RE: Ping IP doesn't work - by Daniel - 08.08.2019, 08:19
RE: Ping IP doesn't work - by MantasJ - 08.08.2019, 08:34
RE: Ping IP doesn't work - by AlexLV - 22.04.2020, 21:23
RE: Ping IP doesn't work - by admin - 23.04.2020, 05:07
RE: Ping IP doesn't work - by AlexLV - 23.04.2020, 08:16
RE: Ping IP doesn't work - by djaval - 24.04.2024, 08:05
RE: Ping IP doesn't work - by admin - 24.04.2024, 08:47

Forum Jump: