Hi Daniel, On 2010-09-23 07:30, vineet daniel wrote: > On Sep 22, 2:20 pm, de...@web.de (Diez B. Roggisch) wrote: >> vineet daniel <vineetdan...@gmail.com> writes: >>> On Sep 21, 9:47 pm, de...@web.de (Diez B. Roggisch) wrote: >>>> vineet daniel <vineetdan...@gmail.com> writes: >>>>> code that I am using is as follows : >> >>>>> #! /usr/bin/env python >>>>> import sys,os >>>>> pid = os.fork() >>>>> os.chdir("/var/www/html/") >>>>> os.setsid() >>>>> os.umask(0) >>>>> #this line will read apache log in real time as redirected from the >>>>> CustomLog directive of Apache. >>>>> log = sys.stdin.readlines() >>>>> f = open('/var/www/logmongo.txt','a') # append log to this text file >>>>> f.write(log)
I guess you'll need some loop to process the input from Apache. > There is a directive in Apache - CustomLog which can redirect logs to > a script or another file by using Pipe. I googled about it and came to > know that this works flawlessly with Perl as Apache treats Perl > scripts as daemon, for Python to take input from Apache, it needs to > work as daemon. Apache will then push its logs lines to this daemon as > input. Perl takes this input as <stdin> but python's stdin is not > working as expected it just takes the file name as given in CustomLog > directive using Pipe i.e if I use CustomLog '|/var/wwww/script.py' Are the _four_ ws intentional? > combined, what script reads is just the file name, how and why I am > not able to figure it out. And thats the reason I am here. I hope > you've got what I am trying to do. Do you have a line for the interpreter at the top of your script, like #!/usr/bin/python Is the script executable (e. g. chmod +x script.py)? Stefan -- http://mail.python.org/mailman/listinfo/python-list