【发布时间】:2021-03-18 18:45:55
【问题描述】:
我正在运行这个 python 脚本来执行命令并将它的输入和输出连接到端口上的客户端。
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()
我面临的问题是 less 命令在客户端打印输出但不打开寻呼机。 有关如何解决此问题的任何想法。
【问题讨论】:
标签: python sockets subprocess pager