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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
pingseems 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.