Skip to content

Instantly share code, notes, and snippets.

@boogheta
Created April 21, 2022 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boogheta/dc41ece149b9abe31525fefbd2425c21 to your computer and use it in GitHub Desktop.
Save boogheta/dc41ece149b9abe31525fefbd2425c21 to your computer and use it in GitHub Desktop.
Test port open
#!/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