I am trying to write a python script where you input a few ips and continuously ping them, then output a result. I wanted to have it loop through the ips and just keep going until stopped however I cannot get that to happen. Also the output if statement always returns false. advise/help?
import os
import subprocess
print ("PingKeep will run a Ping request every 5 seconds on a round of IP's until told to stop (using ctrl+c)." )
ips=[]
n=int(input("How many IP's are we checking: "))
for i in range(1,n+1):
x=str(input("Enter IP number "+str(i)+": "))
ips.append(x)
for ping in range(0,n):
ipd=ips[ping]
res = subprocess.call(['ping', '-n', '3', ipd])
if ipd in str(res):
print ("ping to", ipd, "OK")
elif "failure" in str(res):
print ("ping to", ipd, "recieved no responce")
else:
print ("ping to", ipd, "failed!")