Created
April 21, 2022 12:15
-
-
Save boogheta/dc41ece149b9abe31525fefbd2425c21 to your computer and use it in GitHub Desktop.
Test port open
This file contains 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
#!/usr/bin/env python | |
import sys | |
from socket import socket | |
ports = range(int(sys.argv[1]), int(sys.argv[2])) | |
s = socket() | |
for port in ports: | |
try: | |
print "TEST %s..." % port | |
s.connect(("localhost", port)) | |
s.close() | |
print " -> Port Free" | |
except Exception as e: | |
print " -> Port locked; %s %s" % (type(e), e) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment