TCP port using python - how to forward command output to tcp port? -
i want develop code in python open port in localhost , send logs port. logs nothing command output of python file.
like :
hello.py = 0 while true: print "hello printed %s times." % i+=1 this continuously print statement. want cont. output sent opened port.
can tell me how can same?
thanks in advance
here came with.
to use script :
hello.py | thisscript.py hope wanted.
import socket import sys tcp_ip = '127.0.0.1' tcp_port = 5005 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() this extended specify port argv
Comments
Post a Comment