Created
July 20, 2013 03:57
-
-
Save mlbright/6043795 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
#!/usr/bin/env python | |
# inspired by http://timkay.com/solo/ | |
import socket | |
import sys | |
import subprocess | |
HOST='' | |
port = int(sys.argv[1]) | |
sock = None | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
try: | |
sock.bind((HOST,port)) | |
except socket.error: | |
print("locked!") | |
sock.close() | |
sys.exit(0) | |
subprocess.call(sys.argv[2:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment