summaryrefslogtreecommitdiff
path: root/scripts/ping
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/ping')
-rwxr-xr-xscripts/ping10
1 files changed, 8 insertions, 2 deletions
diff --git a/scripts/ping b/scripts/ping
index e41e334..e8b0471 100755
--- a/scripts/ping
+++ b/scripts/ping
@@ -16,6 +16,7 @@
import os
import sys
+import socket
import ipaddress
options = {
@@ -205,9 +206,14 @@ if __name__ == '__main__':
matched = complete(option)
sys.stdout.write(options[matched[0]]['type'])
sys.exit(0)
-
+
+ try:
+ ip = socket.gethostbyname(host)
+ except socket.gaierror:
+ sys.exit(f'ping: Unknown host: {host}')
+
try:
- version = ipaddress.ip_address(host).version
+ version = ipaddress.ip_address(ip).version
except ValueError:
sys.exit(f'ping: Unknown host: {host}')