so I'm such a noob in Python it's painful but I'm trying to come up with a way to PING a site, then spit out an 'if/else' clause.
So far I have this:
import subprocess
command = "ping -c 3 www.google.com" # the shell command
process = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=None, shell=True)
#Launch the shell command:
output = process.communicate()
print output[0]
Below is where I go awry, here is part two:
if output == 0.00
print "server is good"
else
print "server is hosed"
Obviously part 2 is not working out.
My question is, how do I "read" the results from the ping (the milliseconds) icmp_seq=0 ttl=44 time=13.384 ms
and say "if the ping time is faster than 12.000 ms then do THIS" else "do THAT"
Right now I'm just doing a print but soon I'd like to change that so something else.