如何在pythons Popen中将args传递给args?

2024-09-27 23:27:23 发布

您现在位置:Python中文网/ 问答频道 /正文

import subprocess

command = ["wine"]

arguments = ['/root/Desktop/COLDHEART/exploits/eternalblue/Eternalblue-2.2.0.exe', ' --inconfig /root/Desktop/COLDHEART/exploits/eternalblue/Eternalblue-2.2.0.0.xml', '--targetip 0.0.0.0']

command.extend(arguments)

proc = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]

print(proc)

print("\n Done")

所以我使用subprocess.Popen从命令中获取输出。这个命令在运行两个程序,wine和eternalblue.exe。我需要将参数传递给eternalblue.exe,但是我得到了错误。它似乎采取任何参数,我通过,并试图使用它们的葡萄酒,而不是exe


Tags: 命令rootprocexeargumentscommandsubprocessprint
1条回答
网友
1楼 · 发布于 2024-09-27 23:27:23

根据Python文档

import shlex, subprocess
command_line = raw_input()
## /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'"
args = shlex.split(command_line)
print args
##['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd',"echo '$MONEY'"]
p = subprocess.Popen(args) # Success!

你只需要把你的论点分成两部分。例如, 'inconfig/root/Desktop/COLDHEART/exploits/eternalblue/eternalblue-2.2.0.0.xml'>;'在图','/root/Desktop/COLDHEART/exploits/eternalblue/eternalblue-2.2.0.0.xml'中

相关问题 更多 >

    热门问题