I am running this python script to execute a command and connect it's input and output to a client on the port.
import getpass
import socket
import subprocess
username = getpass.getuser()
host = socket.gethostbyname('')
port = 443
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection = None
while connection is None:
try:
connection = s.connect((host, port))
s.send("[+] We are connected to %s" % username)
while True:
try:
exec_code = s.recv(1024)
if exec_code == "quit":
break
else:
print "1"
proc = subprocess.Popen("less data.txt", shell=True, stdout=s, stdin=s)
proc.wait()
print "2"
except Exception, err:
print err
except Exception, e:
print e
s.close()
The problem I am facing is that less command prints output on the client side but does not opens a pager. Any ideas on how to resolve this thing.