Hi all, i've been receiving the list mail for a few days and read through 
what people seem to need to look at to help others with script problems. I 
included what little bit of code i have for my project below.
Basically i've been going through the Perl by Example book and pulling 
relevant bits out to piece this together.  I want to eventually turn this 
into a web script, but not yet.

I want this script to be able to open the /etc/mail/access file, read 
through it and sort the hopefully 2 columns into seperate arrays. the 
e-mail/domain names to be blocking in the first array and the REJECT, 
RELAY, 500 Message in the second array.  It asks for user input of "which 
doamin to look for" in the list already and runs through to see if it has a 
match.  At the moment when i put in a name i know is in there it comes back 
with the REJECT, which is out of array 2.  The list is seperated by tabs, 
and (honestly) i don't know what to put in the delimeter field to make it 
look for a tab to seperate.

The harder question i have is the second half of the script.  Once it 
determines that no match was found, i want to have it appended to the end 
of array 1, ask for another user input for "How should we treat this email 
/ domain name?" in which user fills in REJECT, RELAY, etc. and then close 
the access file with changes made.

and that's sort of where i'm reading as much as i can and code stops.

Thanks for any advise!


#!/usr/bin/perl -w
#Script to add spam to /etc/mail/access file
#And create and hash of it then restart sendmail

open(NAMES,"/etc/mail/access") || die "Can't open access: $!\n";
while (<NAMES>){
         ( $email, $action )= split('', $_);
         $newarray{$email} = $action;
}
close NAMES;

while(1){
         print "Look for what domain in spam filter? ";
         chomp($email=<STDIN>);
         last unless $email;
         print $newarray{$email},"\n";
}

if <STDIN> <> $email
open(APPEND, ">>/etc/mail/access1") || die "can't open access1 $!\n";
APPEND=<STDIN>
print APPEND "<STDIN>  \n";



David M.R. Freeman
webmaster sysadmin for MMP, Inc.
web:            www.woodfreeman.com
e-mail: [EMAIL PROTECTED]
phone:  (253) 564-5902
fax:            (253) 565-1811

Reply via email to