I have a program running a ping. On my terminal screen i get this:
--- google.com ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 47.963/47.963/47.963/0.000 ms
Connection successful
But on my console i am only getting:
Connection successful
I want my console to show the same ping statistics as my terminal does. I will eventually want to log the ping results onto a txt or csv file, but that will be down the road.
import platform # For getting the operating system name
import subprocess # For executing a shell command
import time
import logging
host = "google.com"
def ping(host):
param = '-n' if platform.system().lower()=='windows' else '-c'
command = ['ping', param, '1', host]
return subprocess.call(command) == 0
while ping(host) == False:
print("There is no network connection")
time.sleep(1)
while ping(host) == True:
print("Connection successful")
time.sleep(1)
How do i get my Terminal Ping statistics to display on my console output?