Hi,
I have a log file directory structure on the apache web server. I would like to develop a way to search the key word
from those log files and show them on the web page.
I use apache 1.3.27 running on RedHat Enterprise Linux AS 2.1/3.0.
Those log files are located at /home/logs and this directory is not export in httpd.conf, which I don't want to.
I wrote a shell script to search the key word, which is job id, and cp the relative log files in a direcotry created
under http document root.
------------
#!/bin/sh
JOBID=$1
if [ -d /var/www/html/$JOBID ]
then
exit
else
mkdir /var/www/html/$JOBID
# Copy the JOBID related batch log files to http directory
BatchDir=`find /home/logs -type f -name "job_$JOBID*.log" -exec grep -w info.batchDir {} \; \
| awk -F: '{ print $NF }' | sort -u`/logs
cp $BatchDir /var/www/html/$JOBID
fi
-----------------------
I would like to turn this script into the cgi script(or something similar function) so it can:
1. A search page that allow users type in job id ($JOBID), this id is unique.
2. Search in the log file named job_$JOBID_*.log and grep the line with key word "info.batchDir"
The line will looks like:
job_295744_20041121.log:20
041121 23:51:28 info.batchDir is:/home/customers/1120200
4
3. Create a directory call $JOBID under http root (/var/www/html) and copy the /home/customers/11202004/l
ogs
directory to /var/www/html/$JOBID
4. Display/create a html page with the content of file list in /var/www/html/$JOBID and each file have
hyperlink.
5. Multiple users request the same job id will display the same page since it's there already.
Please advise.
Thanks very much in advance.
Start Free Trial