LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-24-2004, 07:03 AM   #1
jhill
LQ Newbie
 
Registered: Jul 2004
Location: Cheshire, UK
Distribution: SuSE 9.0
Posts: 6

Rep: Reputation: 0
writing a script to perform a function on each users mail folder


I have spamassassin working as a spam filter on my fileserver. I want to modify the setup so that spamassassin autolearns which emails are spam and which are not. I understand that it is best to do this using the spamassassin command sa-learn called through a cron task. sa-learn takes a directory as an input so it is possible to say "this folder contains spam" and teach spamassassin.

My problem is how to write the script that calls the sa-learn function for each of the system users.

The users folder structure is something along the lines of
Quote:
/mail/user1/ (not spam)
/mail/user1/spam (spam)
I want to be able to specify these 2 folders for each user and not worry about modifying the script if I add or remove a user.

Would the best way be to use a for loop along the lines of
Quote:
for user in allUsers
or base it on the directories for each user, ie if a directory exists perform function?

What commands can I use for these loops?

Thanks.
 
Old 08-24-2004, 07:23 AM   #2
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Hmmm... not to good with SpamAssassin as I don't run my own mail server, but if all your users are user1, user2, user3, user[...] then this should do the trick:

# sa-learn /mail/user*/spam

if they're not, and they most likely aren't, try

# sa-learn /mail/*/spam

this should prevent you from having to modify the code. Now: if you have multiple directories in /mail, such as a /mail/etc (?) or something, you'll probably need to specifically exclude those directories if that's possible. Try the man pages for xarg, ls, and commands of that nature. Sorry if I couldn't be more help
 
Old 08-24-2004, 08:18 AM   #3
jhill
LQ Newbie
 
Registered: Jul 2004
Location: Cheshire, UK
Distribution: SuSE 9.0
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks scuzzman. That works a treat. I was expecting a more complicated solution!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing shell script with mail < logfile humbletech99 Programming 2 11-22-2005 09:20 AM
anonymous folder writing with vsftpd thomas.jt Linux - Networking 3 10-31-2005 09:18 PM
perl script help required to create users and changing the owner to pericular folder sridhar11 Programming 2 10-25-2005 03:16 PM
Writing to a shared home folder confused_bof Linux - Networking 5 05-18-2004 07:50 AM
E-Mail notification to users via SMS (gateway script ok, but notification script?!?) Riku2015 Linux - Networking 10 03-08-2002 11:16 AM


All times are GMT -5. The time now is 03:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration