我希望在命令提示符中运行一些命令后,整齐地显示 python 文件的输出。
目前,我的 PHP 代码的一部分如下所示:
$output2 = shell_exec('python amassprocess.py 2>&1' . $asnum);
echo $output2
它基本上将用户输入发送到 python 文件 amassprocess.py 并使用用户输入运行该文件。
amassprocess.py 文件目前如下所示:
import os, sys
#asnum = sys.argv[1]
asnum = "46489"
print("Here is a list of top level seed domain related to the AS Number provided:")
topdomain = os.system('cmd /c "amass.exe intel -asn {}"'.format(asnum))
for i in topdomain:
print(i)
print("<br>")
PS:忽略2个asnum,其中一个用于测试
运行 python 脚本的结果输出如下:
Here is a list of top level seed domain related to the AS Number provided:
ttvnw.net
justin.tv
twitch.tv
socialcam.com
Traceback (most recent call last):
File "z:/xampp/htdocs/majorproject/amassprocess.py", line 8, in <module>
for i in topdomain:
TypeError: 'int' object is not iterable
但是,我希望运行 python 脚本时的输出如下:
Here is a list of top level seed domain related to the AS Number provided:
ttvnw.net
<br>
justin.tv
<br>
twitch.tv
<br>
socialcam.com
这样当它在 PHP 中显示时,它看起来像这样:
Here is a list of top level seed domain related to the AS Number provided:
ttvnw.net
justin.tv
twitch.tv
socialcam.com
目前在 PHP 中,结果都只显示在一行中,如下所示:
ttvnw.net justin.tv twitch.tv twitchcon.com socialcam.com Traceback (most recent call last): File "amassprocess.py", line 7, in for i in topdomain: TypeError: 'int' object is not iterable
我将不胜感激任何帮助或想法。谢谢。
慕田峪4524236
qq_遁去的一_1