Hi i want to write in excel file output from my program in Python. This program ping every ip adress from txt file.
This is my code:
import os
with open("ip.txt", "r+") as ips_file:
ips = [ip.strip() for ip in ips_file.readlines()]
with open("IPsCheck.txt", "w") as available_ips_file:
for ip in ips:
response = os.system('ping {} -n 2 -w 2'.format(ip))
if response == 0:
available_ips_file.write(ip + "\n")
else:
print('server {} not available'.format(ip))