mIRC Homepage
Posted By: bwr30060 Edit Apache log file (using /filter?) - 29/03/06 03:10 AM
Hi,

I haven't worked with /filter, so I'm not sure how to do this, but I figured that /filter would be the command to use. When I access my website from a browser, it adds my connection to the log file, which can add quite a few lines if I'm testing something. I'd like to have a mIRC script that will search for my entries in the log file and delete them. If I understand correctly, filter will act on that file and write the matches to a new file. Would there be a way to write the new file with all my entries taken out, delete the old log and rename the new file with the old name? The entries look like this (with some variations depending on the page visited):

192.168.1.97 - - [28/Mar/2006:18:09:22 -0500] "GET /project_files/image012.jpg HTTP/1.1" 200 1182

The log file is located at "C:\Program Files\Apache Group\Apache2\logs\access.log". Thanks for any help.
Posted By: Bob57 Re: Edit Apache log file (using /filter?) - 29/03/06 04:25 PM
Not sure I fully understand the situation, but say for example 192.168.1.97 is your address and you want to strip all lines starting with it from the log file:
Code:
/Apache.Strip {
  var %LogFile = “C:\Program Files\Apache Group\Apache2\logs\access.log”
  filter -ffxc %LogFile %LogFile 192.168.1.97*
} 

See Help for what the -ffxc switches do.
Posted By: bwr30060 Re: Edit Apache log file (using /filter?) - 29/03/06 06:51 PM
Thanks, that's what I needed. And I looked up those options. x excludes matches, the f's are because they're both files, and c clears the file before writing. smile
Posted By: bwr30060 Re: Edit Apache log file (using /filter?) - 29/03/06 08:03 PM
Hey,

I just ran that code and it didn't work. I made a copy of the log file and put it on my desktop so I wasn't messing with the real one when I tested, and the lines with that IP are still there. Any ideas? Here's the code with the small change for location.
Code:
/Apache.Strip {  var %LogFile = “C:\Documents and Settings\Owner\Desktop\access.log”  filter -ffxc %LogFile %LogFile 192.168.1.97*} 
Posted By: xDaeMoN Re: Edit Apache log file (using /filter?) - 29/03/06 09:11 PM
There should be a "|" before filter so mIRC can evaluate the word after it.
Posted By: bwr30060 Re: Edit Apache log file (using /filter?) - 30/03/06 05:19 PM
Thanks, I got that working (with Bob57's help). I made the alias two lines, and Bob helped me figure out another change to make it work. It seems like one part of the problem was a mIRC version issue. He's using 6.16 and I'm using 6.17. Here's the end result
Code:
/Apache.Strip {  var %LogFile = $shortfn( C:\Program Files\Apache Group\Apache2\logs\access.log )  
  filter -ffxc %LogFile %LogFile 192.168.1.101* 
}


I changed the IP to my new one since I got a firewall, and changed the file path to the working file after I tested it.
© mIRC Discussion Forums