【发布时间】:2021-02-23 01:28:59
【问题描述】:
这就是我得到的。 (我知道这很糟糕)它需要一个参数,即域名。在其上运行 subfinder,然后将结果写入结果。
def getSubs(command):
result = subprocess.check_output(command, shell=True, universal_newlines=True)
with open('results', 'w') as file_contents:
for i in result:
file_contents.write(i)
http_check()
getSubs(['subfinder -d' 'sys.argv[1]'])
现在我只想看看我是否可以打开文件以将每一行输入一个新命令,并担心稍后将其写入另一个文件。我注释掉了所有内容,除了:
def httpCheck():
with open('results', 'r') as file_to_iterate:
for scan in file_to_iterate:
p1 = subprocess.Popen([f"echo", "{scan}"], stdout=subprocess.PIPE)
p2 = subprocess.Popen(['httprobe'], stdin=p1.stdout, shell=True, stdout=subprocess.PIPE)
p1.stdout.close()
output = p2.communicate()[0]
print(output)
返回:
b''
b''
b''
我怎样才能让它打印出结果?或者参考。此外,new_file 现在只包含三行:
domain.com
another_domain.com
non-existent.com
【问题讨论】:
标签: python-3.x subprocess