0

I am trying to wring code for IP ping monitor below code works well

response = os.system("ping -c 1 " + "google.com")
        print(response)
        if response == 0:
            print("Google is up!")
        else:
            print("Google is down!")

Its gives the output like below

--- google.com ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 14.138/14.138/14.138/0.000 ms
0
Google is up!

But i need to suppress the console log. I need output like

Google is up!

response = os.system("ping -c 1 " + "google.com" >/dev/null 2>&1') appending the " >/dev/null 2>&1" has hide the console log. But its return always some numerical value. So i got result like always down.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
ARAVIND RAJ
  • 486
  • 5
  • 11

0 Answers0