Skip to content

Instantly share code, notes, and snippets.

@iqfareez
Last active January 29, 2021 09:22
Show Gist options
  • Save iqfareez/de94ca00cd0264f144e87d7fd05a9d46 to your computer and use it in GitHub Desktop.
Save iqfareez/de94ca00cd0264f144e87d7fd05a9d46 to your computer and use it in GitHub Desktop.
Windows ping to Google using Python
import os
def main():
while True:
# Input can be Y/N or small letter y/n or word like yes/no
response = input('Do ping? (y/n)\n>>> ')
response = response[0] # Get the first char
response = response.lower() # Convert to lower case
if response == 'y':
DoPing()
break
elif response == 'n':
print('\n:")\n')
break
else:
print('You didn\'t answer that question. Please re-enter value (y/n)')
continue
def DoPing():
"""
Ping to Google
"""
os.system('ping www.google.com')
print('\nPing donde\n')
if __name__ == "__main__":
main()
@iqfareez
Copy link
Author

iqfareez commented Nov 2, 2020

Example output:

PS C:\Users\maple> & C:/Python38/python.exe c:/Users/maple/Desktop/idle1.py
Do ping? (y/n)
>>> yes

Pinging www.google.com [172.217.174.164] with 32 bytes of data:
Reply from 172.217.174.164: bytes=32 time=204ms TTL=114
Reply from 172.217.174.164: bytes=32 time=8ms TTL=114
Reply from 172.217.174.164: bytes=32 time=25ms TTL=114
Reply from 172.217.174.164: bytes=32 time=23ms TTL=114

Ping statistics for 172.217.174.164:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 8ms, Maximum = 204ms, Average = 65ms

Ping donde

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment