diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-03-08 20:24:55 +0000 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-03-08 20:24:55 +0000 |
commit | c5a3cfc0092f86f101b4bc6825a3b77bc8ee1de6 (patch) | |
tree | 3b24d48306dd2583e67a7888b0f91358d1921121 /scripts | |
parent | 833508908486f8ff5747d914e945afed5f0eb896 (diff) | |
download | vyatta-op-c5a3cfc0092f86f101b4bc6825a3b77bc8ee1de6.tar.gz vyatta-op-c5a3cfc0092f86f101b4bc6825a3b77bc8ee1de6.zip |
ping: T2109: fix/add name resolution
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/ping | 10 |
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}') |