Re: [Exim] Sed Regex help

Top Page
Delete this message
Reply to this message
Author: Jez Hancock
Date:  
To: Marc Perkel
CC: exim-users
Subject: Re: [Exim] Sed Regex help
On Tue, Jan 06, 2004 at 06:31:18PM -0800, Marc Perkel wrote:
> I'm a little slow that this so I can use the help of someone smarter
> than me.
>
> I'm needing to write a script so that if someone hits a specific web
> page - it locks out their IP address. I have part of it written. So this
> should be simple. The IP address is the first field in the lines that
> I'm looking at.
>
> So I'm going to run:
>
> tail -f logfile|grep webpage| something | blockip <the ip address>

something could be something like:

awk '{print $1}'

assuming the IP address is in the very first space-delimited field of
the logfile line ($2 would capture the second space-delimited field
etc).

cut -f1 -d" "

would do similar.

I'm with the other chap that mentioned using server side webscripting to
make the operation easier - for example in php you could do the whole
'blockip' thing in one fell swoop - in the page that badusers hit:

<?php
# just use backtick operator to execute 'blockip' on the remote user's
# ip - might need to be careful it's not a web proxy though! :P
`path/to/blockip $_SERVER["REMOTE_ADDR"]`;
?>

Out of curiousity what does this have to do with Exim?!

--
Jez Hancock
- System Administrator / PHP Developer

http://munk.nu/
http://jez.hancock-family.com/  - personal weblog
http://ipfwstats.sf.net/        - ipfw peruser traffic logging