Python Forum
run a command, capture output, what form do you want?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
run a command, capture output, what form do you want?
#7
(Oct-28-2022, 11:27 PM)Skaperen Wrote: now try calling something in some Python3 code and capturing each ping response and output the time since the previous response (beginning of command for first response). the unit of delta time can be in milliseconds. at the end give the delta stats: lowest, median, average, highest
icmplib(The best Python implementation ICMP protocol) will give timings of diffrent ping times used.
from icmplib import ping

host = ping('python-forum.io', count=4)
print(host)
Output:
104.21.27.41 ------------------------------------------------------------ Packets sent: 4 Packets received: 4 Packet loss: 0.0% Round-trip times: 24.0 ms / 29.25 ms / 33.0 ms Jitter: 5.0 ms ----------------------------------------------------------
# min, avg, max, jitter(variance of the latency of packets flowing through the network)
>>> host.min_rtt
29.0
>>> host.avg_rtt  
32.0
>>> host.max_rtt
35.0
>>> host.jitter
5.333
Reply


Messages In This Thread
RE: run a command, capture output, what form do you want? - by snippsat - Oct-30-2022, 07:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to capture output from license() in one Python process? Skaperen 0 982 Dec-08-2022, 03:35 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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