Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ping with output
#2
Don't use os.system for that.

Example

from subprocess import check_output
out = check_output(["ping", "-c 5", "8.8.8.8"])

print("".join(map(chr, out)))
Output:
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=57 time=27.3 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=57 time=28.2 ms 64 bytes from 8.8.8.8: icmp_seq=3 ttl=57 time=28.2 ms 64 bytes from 8.8.8.8: icmp_seq=4 ttl=57 time=27.6 ms 64 bytes from 8.8.8.8: icmp_seq=5 ttl=57 time=27.9 ms --- 8.8.8.8 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 27.394/27.886/28.269/0.389 ms
Reply


Messages In This Thread
ping with output - by jacklee26 - Nov-28-2019, 02:19 AM
RE: ping with output - by Axel_Erfurt - Nov-28-2019, 01:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need some guidance on a script to ping a list of ip's cubangt 11 6,891 Aug-10-2023, 02:39 PM
Last Post: snippsat
  non-stop ping script kucingkembar 1 2,129 Aug-23-2022, 06:29 AM
Last Post: menator01
  Ping command using python 3.6.5 Martin2998 6 27,671 Apr-19-2021, 06:24 PM
Last Post: blazejwiecha
  Create a program that PING a list of IPs skaailet 7 10,129 Mar-26-2020, 10:46 PM
Last Post: snippsat
  PING PONG GAME akea 0 6,399 May-08-2019, 04:30 PM
Last Post: akea
  Ping Code Problem MTom5 1 3,264 Sep-04-2018, 09:58 PM
Last Post: MTom5
  ping and pong run both well sylas 1 3,871 Sep-24-2017, 05:14 PM
Last Post: sylas
  Ping Sweep help The501stOfNoobPy 5 8,510 Jun-26-2017, 10:22 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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