Just curious to see if there is a lua way to ping a server without using os.execute. The purpose being to see if a server is up.
I checked the lua sockets library but I don't think ICMP is supported? Any idea?
To the best of my knowledge, no, you can't send ICMP raw packets without root access. That's not a Lua limitation, it's an OS restriction.
To get root access, the best way is to have a small well tested program that's SUID root rather than changing your entire application with Lua to be SUID root. This means you'll end up using os.execute(). And rather than writing your own program, the OS provided ping
seems to be a nice command for solving your issue.
I agree it's not ideal (especially since this creates OS specific code to handle the various ping commands). But without a SUID function call, I don't think there's any better way.