I have a CSV file with the hostnames of 6,000+ servers. I need to ping each one.
Any idea how to create a python script like this?
Thanks!
I have a CSV file with the hostnames of 6,000+ servers. I need to ping each one.
Any idea how to create a python script like this?
Thanks!
Open file, for-loop through hosts (easiest if 1 per line), then ping.
To learn how to ping, try reading this article: Pinging servers in Python
Then, just make a small routine that opens file, loops through lines, and pings each one.
with open("file") as f:
for host in f:
ping(host) # <- not legit; replace this line; see comment below
Note: you will need to replace "ping(host)" with code that you create after being inspired by the "Pinging servers in Python" Q&A or another article... or by just flat-out copying their example.