s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
while True:
    line = sys.stdin.readline()
if line:
    s.send(line)
else:
    break
s.close()
TCP port using python - how to forward command output to tcp port?