I'm trying to ping an IP and insert the entire CMD output into a text file using Python3. getIP() returns a list of IPs to ping. I do not need to append each output of every ping because the file is meant to be temporary and overwritten with each ping. My ultimate goal is to parse the avg rtt from the ping output.
IP = getIP()
with open('out.txt', 'w') as f:
for ip in IP:
s = str(os.system('ping %s -c 4' % ip))
f.write(s)
time.sleep(3)
Thanks