Created
November 16, 2022 17:32
Revisions
-
wsummerhill created this gist
Nov 16, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ #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