Mar-24-2020, 07:29 PM
Could somebody help me creating a program that Ping a list of IP adresses and save thta result of that Pinf in a text file in order to have a historic record
I made tis code but it is not working as expected
I made tis code but it is not working as expected
import os
import csv
import time
import datetime
import logging
def check_ping(hostname):
response = os.system("fping -r 10 -q " + hostname + " >/dev/null")
if response == 0:
check_ping = "[OK]"
else:
check_ping = "[Error]"
return check_ping
with open('ip-source.txt') as file:
dump = file.read()
dump = dump.splitlines()
for ip in dump:
os.system('cls')
print('Pinging now:', ip)
print('-'*60)
os.system('ping -n 2 {}'.format(ip))
print('-'*60)
time.sleep(5)
