Created
February 24, 2026 23:04
-
-
Save CarlFK/7f55b35336bf3c061295fa37438a8979 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from subprocess import Popen, PIPE, TimeoutExpired | |
| from pprint import pprint | |
| import json | |
| import time | |
| def ping(ip): | |
| cmd = ["ping", "-c", "3", "-w", "5", ip] | |
| proc = Popen(cmd, stdin=PIPE, stdout=PIPE,stderr=PIPE) | |
| while (line := proc.stdout.readline()) or (proc.poll() is not None): | |
| line = line.decode().strip() | |
| print(line) | |
| time.sleep(1) | |
| def main(): | |
| ping("127.0.0.1") | |
| if __name__=='__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment