I have this code :
import os, time, requests
url = 'WEBHOOK URL'
while True:
hostname = "google.com" #example
response = os.system("ping -c 1 " + hostname)
if response == 0:
print (hostname, 'est en ligne!')
ping = os.system("ping -c 4 " + hostname + "| tail -1| awk -F '/' '{print $5}' ")
data = {"content" : "Service online with ping of "+ str(ping) +"ms",
"username" : "Ping Bot" }
requests.post(url, json = data)
The bot should return a values likes :
Service online with ping of 29.815 ms
But i got this :
Service online with ping of 0 ms
I don't know why i got 0 instead of my variable values ...
Thanks for you're assistance