Created
November 16, 2022 17:32
-
-
Save wsummerhill/17f997ea493e38efda03df6fd03f2eb6 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
#Quick Python script to loop through hostnames from file and resolve their IPs | |
import socket, sys | |
hostsFile = sys.argv[1] | |
with open(hostsFile) as file: | |
for line in file: | |
try: | |
host = line.strip() | |
ip = socket.gethostbyname(host) | |
print(f'Host: {host} = {ip}') | |
except socket.gaierror as e: | |
#print(f'Error: IP not found for {host}') | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment