python check if ip is up or down

Solutions on MaxInterview for python check if ip is up or down by the best coders in the world

showing results for - "python check if ip is up or down"
Bethany
15 Aug 2018
1import nmap, socket
2ip_addr = input('Enter ip or url to check if it is up or down: ')
3scanner = nmap.PortScanner()
4host = socket.gethostbyname(ip_addr)
5scanner.scan(host, '1', '-v')
6print("IP Status: ", scanner[host].state())