mIRC Home    About    Download    Register    News    Help

Print Thread
Edit Apache log file (using /filter?) #145888 29/03/06 03:10 AM
Joined: May 2005
Posts: 449
bwr30060 Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
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.

Re: Edit Apache log file (using /filter?) #145889 29/03/06 04:25 PM
Joined: Dec 2004
Posts: 66
B
Bob57 Offline
Babel fish
Offline
Babel fish
B
Joined: Dec 2004
Posts: 66
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.

Re: Edit Apache log file (using /filter?) #145890 29/03/06 06:51 PM
Joined: May 2005
Posts: 449
bwr30060 Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
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

Re: Edit Apache log file (using /filter?) #145891 29/03/06 08:03 PM
Joined: May 2005
Posts: 449
bwr30060 Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
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*} 

Re: Edit Apache log file (using /filter?) #145892 29/03/06 09:11 PM
Joined: Mar 2005
Posts: 420
X
xDaeMoN Offline
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
There should be a "|" before filter so mIRC can evaluate the word after it.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Re: Edit Apache log file (using /filter?) #145893 30/03/06 05:19 PM
Joined: May 2005
Posts: 449
bwr30060 Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
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.