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
精彩评论