Add IP commandline argument
This commit is contained in:
parent
ccac19df6c
commit
ecc73b49de
@ -24,10 +24,8 @@ import threading
|
||||
import queue
|
||||
|
||||
bufferSize = 1000 # buffer size in bytes
|
||||
serverAddr = ("127.0.0.1",12000)
|
||||
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
|
||||
class stdoutThread(threading.Thread):
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
@ -57,11 +55,15 @@ def makePayload(lst):
|
||||
return cmdBytes
|
||||
|
||||
def main():
|
||||
global serverAddr
|
||||
serverAddr = sys.argv[1].rsplit(":",1)
|
||||
serverAddr[1] = int(serverAddr[1])
|
||||
serverAddr = tuple(serverAddr)
|
||||
connection.settimeout(15)
|
||||
connection.connect(serverAddr)
|
||||
connection.sendall(makePayload(sys.argv[1:]))
|
||||
connection.sendall(makePayload(sys.argv[2:]))
|
||||
|
||||
if sys.argv[1] == "watch":
|
||||
if sys.argv[2] == "watch":
|
||||
stdoutThr = stdoutThread()
|
||||
stdoutThr.start()
|
||||
while True:
|
||||
@ -69,7 +71,7 @@ def main():
|
||||
if data == b"": return
|
||||
stdoutThr.queue.put(data)
|
||||
|
||||
if sys.argv[1] == "broadcast":
|
||||
if sys.argv[2] == "broadcast":
|
||||
while True:
|
||||
data = sys.stdin.buffer.read(bufferSize)
|
||||
connection.sendall(data)
|
||||
|
Loading…
Reference in New Issue
Block a user