开发者

Test Apache config file from Python

开发者 https://www.devze.com 2023-03-31 19:56 出处:网络
How would I go about testing the apache config file from python?I开发者_开发知识库\'ve trying using the \"os.popen\" with \"text = stdout_handle.read() to get the result, but nothing happens.

How would I go about testing the apache config file from python? I开发者_开发知识库've trying using the "os.popen" with "text = stdout_handle.read() to get the result, but nothing happens.

Any help would be great :)


I'm guessing you're trying to automate apachectl configtest? Have you tried subprocess.Popen? Something like the following should get you in started:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消