I have a python script, that is working only if my server is available. So before the script is beginning, i want to ping my server or rather checking the availability of the server.
There are already some related SO questions. E.g
-
response = pyping.ping('Your IP') if response.ret_code == 0: print("reachable") else: print("unreachable")
-
response = os.system("ping -c 1 " + hostname)
These answers works well, but only as ROOT user! When i use this solutions as a common user i get the following error message:
ping: Lacking privilege for raw socket.
I need a solution, that i can do that as a common user, because i run this script in a jenkins job and have not the option to run in as root.