Beginner with a beginner question: I am trying to build a python program to ping a csv file of ip addresses.
This script is nearly there, however when I convert the csv data to a list and use the for loop on it... the brackets and quotes remain in the ip address ['10.10.10.1'] which prevents me from pinging.
I know there are numerous ways to remove quotes/brackets from list items, but what would work best here?
I think I am nearly there, what is a simple solution to this?
import os
import csv
csvFile = open('hosts.csv')
csvReader = csv.reader(csvFile)
csvData = list(csvReader)
for ip in csvData:
response = os.system('ping ' + str(ip))
if response == 0:
print(ip, 'is up')
else:
print(ip, 'is down')