从Python测试Apache配置文件



如何从python测试apache配置文件?我试着用"os"。打开" with "text = stdout_handle.read()来获取结果,但是没有任何反应。

如果有任何帮助就太好了

我猜你在尝试自动化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

最新更新