Python Forum
Create a program that PING a list of IPs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create a program that PING a list of IPs
#1
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


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)
Reply


Messages In This Thread
Create a program that PING a list of IPs - by skaailet - Mar-24-2020, 07:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Program to find Mode of a list PythonBoy 6 2,718 Sep-12-2023, 09:31 AM
Last Post: PythonBoy
  Need some guidance on a script to ping a list of ip's cubangt 11 7,352 Aug-10-2023, 02:39 PM
Last Post: snippsat
  Delete strings from a list to create a new only number list Dvdscot 8 3,579 May-01-2023, 09:06 PM
Last Post: deanhystad
  [split] why can't i create a list of numbers (ints) with random.randrange() astral_travel 7 3,043 Oct-23-2022, 11:13 PM
Last Post: Pedroski55
  non-stop ping script kucingkembar 1 2,200 Aug-23-2022, 06:29 AM
Last Post: menator01
  how to easily create a list of already existing item CompleteNewb 15 6,521 Jan-06-2022, 12:48 AM
Last Post: CompleteNewb
  Create SQLite columns from a list or tuple? snakes 6 12,852 May-04-2021, 12:06 PM
Last Post: snakes
  Ping command using python 3.6.5 Martin2998 6 28,648 Apr-19-2021, 06:24 PM
Last Post: blazejwiecha
  Create variable and list dynamically quest_ 12 6,845 Jan-26-2021, 07:14 PM
Last Post: quest_
  How to create a linked list and call it? loves 12 8,691 Nov-22-2020, 03:50 PM
Last Post: loves

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020