Answers for "ping using python with ip address"

2

python ping ip address

import os

ip_list = ['8.8.8.8']
for ip in ip_list:
    response = os.popen(f"ping {ip}").read()
    if "Received = 4" in response:
        print(f"UP {ip} Ping Successful")
    else:
        print(f"DOWN {ip} Ping Unsuccessful")
Posted by: Guest on August-22-2020
0

ping with python

import subprocess

def main():
    host = input("Enter Host: ")
    packet = int(input("nEnter Packet: "))
    print("n")
    ping = subprocess.getoutput(f"ping -w {packet} {host}")
    print(ping)

main()
Posted by: Guest on September-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language