Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

ping with python

import subprocess

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

main()
Comment

ping from python

from pythonping import ping

def ping_host(host):
    ping_result = ping(target=host, count=10, timeout=2)

    return {
        'host': host,
        'avg_latency': ping_result.rtt_avg_ms,
        'min_latency': ping_result.rtt_min_ms,
        'max_latency': ping_result.rtt_max_ms,
        'packet_loss': ping_result.packet_loss
    }

hosts = [
    '192.168.48.1',
    '192.168.48.135'
]

for host in hosts:
    print(ping_host(host))
Comment

how to get ping from computer IN PYTHON

st = Speedtest()
    print("Download:=>", st.download())
    print("upload:=>", st.upload())
    st.get_servers([])
    print("Ping :=>", st.results.ping)
Comment

PREVIOUS NEXT
Code Example
Python :: python change version 
Python :: df dtype 
Python :: why python stops after plt.show() 
Python :: how to check system has internet using python 
Python :: Python Difference between two timedelta objects 
Python :: python slice last 2 items of list 
Python :: how to find number of categories in python 
Python :: Python update to beginning of dictionary 
Python :: python array linspace 
Python :: flask tutorial 
Python :: django search pagination 
Python :: plotly dash datatable column width 
Python :: check for changed model fields in djnago signal 
Python :: hide verbose in pip install 
Python :: Anderson-Darling test in python 
Python :: python socket github 
Python :: run django server on any network address of the system 
Python :: how to make a pattern in python in one line 
Python :: python yield from 
Python :: retrieve content inside the meta tag python 
Python :: python button graphics.py 
Python :: python wifi moudel [WinError 2] The system cannot find the file specified 
Python :: Python Permutation without built-in function [itertools] for Lists 
Python :: python remove table widget numbers 
Python :: Object of type datetime is not JSON serializable 
Python :: python select from list by boolean list 
Python :: how to access a txt file through os library in python 
Python :: get script text selenium python 
Python :: length of dictionary python 
Python :: wordcount pyspark 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =