gpt4 book ai didi

python - 从 Python 测试 Apache 配置文件

转载 作者:行者123 更新时间:2023-11-28 20:46:35 25 4
gpt4 key购买 nike

我将如何从 python 测试 apache 配置文件?我尝试使用带有“text = stdout_handle.read()”的“os.popen”来获得结果,但没有任何反应。

任何帮助都会很棒 :)

最佳答案

我猜您正在尝试自动化apachectl configtest?你试过subprocess.Popen吗?像下面这样的东西应该让你开始:

from subprocess import Popen, PIPE

args = ['/usr/bin/apachectl','configtest']

result = Popen(args,stdout=PIPE,stderr=PIPE).communicate()
# result[0] will be the standard output, result[1] will be the stderr output

http://docs.python.org/library/subprocess.html#popen-objects

关于python - 从 Python 测试 Apache 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7257442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com