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?
#3
(Oct-27-2022, 07:04 PM)Skaperen Wrote: what if the command is a network ping and you want each ping result as soon as the command outputs it?
Output:
λ ping python-forum.io | tee foo.txt PING python-forum.io(2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3)) 56 data bytes 64 bytes from 2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3): icmp_seq=1 ttl=59 time=11.8 ms 64 bytes from 2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3): icmp_seq=2 ttl=59 time=11.4 ms 64 bytes from 2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3): icmp_seq=3 ttl=59 time=11.3 ms 64 bytes from 2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3): icmp_seq=4 ttl=59 time=11.5 ms ^C λ cat foo.txt PING python-forum.io(2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3)) 56 data bytes 64 bytes from 2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3): icmp_seq=1 ttl=59 time=11.8 ms 64 bytes from 2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3): icmp_seq=2 ttl=59 time=11.4 ms 64 bytes from 2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3): icmp_seq=3 ttl=59 time=11.3 ms 64 bytes from 2606:4700:3037::ac43:a8e3 (2606:4700:3037::ac43:a8e3): icmp_seq=4 ttl=59 time=11.5 ms
Reply


Messages In This Thread
RE: run a command, capture output, what form do you want? - by Gribouillis - Oct-27-2022, 08:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to capture output from license() in one Python process? Skaperen 0 987 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