#!/usr/bin/perl -w use strict; my $file = '/var/tmp/exim_deny'; my $ip = shift; die "No argument" unless defined $ip; die "Invalid argument |$ip|" unless $ip =~ /^\d+\.\d+\.\d+\.\d+$/; # (at this point you _could_ take a look in the file and see # if the address is already there - can happen occasionally # e.g when two concurrent dictionary-scan attacks are detected # from the same IP). # Since we're doing an append we can ignore file locking... # (and it's not going to be the end of the world if we sometimes # manage to list the same address twice...) open OUT, ">>$file" or die "Couldn't open file, $!"; my $datestamp = scalar localtime; print OUT "\n\# $datestamp\n$ip\n"; close OUT;