Answer the question
In order to leave comments, you need to log in
How to get the output of a ping command in Python?
To study python, I tried to write my own bike - a pinger of a certain host.
Actually, the ping command itself looks like this (I found it on some site):
result=subprocess.call(["ping",'-n','1', str(address)],shell=True,stdout=subprocess.PIPE)
Answer the question
In order to leave comments, you need to log in
Try to use http://amoffat.github.io/sh/
>>> from sh import ping
>>> res = ping("-c", 1, 'yandex.ru')
>>> res
PING yandex.ru ( 93.158.134.11): 56 data bytes
64 bytes from 93.158.134.11: icmp_seq=0 ttl=57 time=34.563 ms
--- yandex.ru ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round- trip min/avg/max/stddev = 34.563/34.563/34.563/0.000 ms
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question