Re: spam script
That works perfectly!! :D I had never thought of using -path and -f Thank you very much for your kind help :) Nick Bowie Bailey wrote: Nicholas Payne-Roberts wrote: I think my problem is with the usage of the rm command. Even when i execute it on its own (not within find) it fails to delete the file: rm -f /home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/* Executes with no error and fails to delete the contents of the directory. Could this simply then be due to the fact that rm will not delete files in a folder using * unless you are currently inside that directory? I think it is due to the space in the directory name. What I would suggest is modifying the find command so that it finds the individual files rather than the directory. Try this: find /home/vpopmail/domains -path "*/.Junk E-mail/cur/*" -type f -exec rm {} \;
Re: spam script
ah right, excellent, i shall have a play with this and tailor it to my setup, thanks Dave. DAve wrote: Nicholas Payne-Roberts wrote: I think my problem is with the usage of the rm command. Even when i execute it on its own (not within find) it fails to delete the file: rm -f /home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/* Executes with no error and fails to delete the contents of the directory. Could this simply then be due to the fact that rm will not delete files in a folder using * unless you are currently inside that directory? Not entirely sure this will help but here is a snippet from my spam script which deletes all spam messages over three days old. We run it every night. SPAM_PATH="$DOMAIN_PATH/.SPAM" if [ -d $SPAM_PATH/new ]; then OLDSPAMNEW=`find $SPAM_PATH/new -type f -ctime +3 -exec rm {} \;` OLDSPAMCUR=`find $SPAM_PATH/cur -type f -ctime +3 -exec rm {} \;` echo " Spam messages removed from $SPAM_PATH" >> $TMP else echo " No spam folder found, moving on." >> $TMP fi $SPAM_PATH is a domain path taken from the vpopmail database plus the name of the spam folder. I do a quick query to see who has spam filtering turned on and who doesn't. Then I just run through the list. It's worked for about two years now and always finds/deletes the spam messages. DAve
Re: spam script
I think my problem is with the usage of the rm command. Even when i execute it on its own (not within find) it fails to delete the file: rm -f /home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/* Executes with no error and fails to delete the contents of the directory. Could this simply then be due to the fact that rm will not delete files in a folder using * unless you are currently inside that directory? Nicholas Payne-Roberts wrote: nope, that didn't have any effect either :( I've tried with -v option but that doesn't show me anything else going on either. Thanks for your suggestions though Sietse. Sietse van Zanen wrote: Just a thought, try escapeing the * find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/\* \; Maybe that helps. -Sietse ________ From: Nicholas Payne-Roberts [mailto:[EMAIL PROTECTED] Sent: Wed 12-Jul-06 15:12 To: Sietse van Zanen Subject: Re: spam script find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \; It just seems to execute without any errors but when you look in any of the cur directories, the files are still there: find /home/vpopmail/domains -name ".Junk E-mail" -exec ls -l {}/cur \; total 0 total 0 total 0 total 0 total 0 total 0 total 0 total 0 -rw-r--r-- 1 root root 0 Jul 12 16:09 test <-- a touch'd file i just placed into a cur directory to test the rm command. Sietse van Zanen wrote: I thought that was what you wanted. Otherwise I would expect the original command with * to be working well in removing the files in the ../cur directory. What's going wrong with that than? -Sietse From: Nicholas Payne-Roberts [mailto:[EMAIL PROTECTED] Sent: Wed 12-Jul-06 14:55 To: users@spamassassin.apache.org Subject: Re: spam script That deleted all of the cur directory within the .Junk E-mail directory. Sietse van Zanen wrote: Loose the * and do rm -rf (recursively deletes the directory) -Sietse From: Nicholas Payne-Roberts [mailto:[EMAIL PROTECTED] Sent: Wed 12-Jul-06 14:24 To: users@spamassassin.apache.org Subject: spam script I am now trying to figure out how to use find in a similar way to tidy up those Junk E-mail directories by deleting them after they have been used to learn from. This is what i've tried, but the rm command doesn't seem to like working with files within the /cur directory... find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \; If i try the above and omit the astrix, it complains about cur being a directory: rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/': Is a directory Thanks in advance for any suggestions :) Nick Chris Lear wrote: * Nicholas Payne-Roberts wrote (11/07/06 11:58): Does anybody know a good way to script sa-learn to daily check on junk e-mail folders? i'm currently trying the following line in a cron.daily script, but its throwing up an error: find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam cur {} \; Your --exec subcommand is the problem. The {} expands to the full path of the found file. It doesn't change directory. A version that might work is find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam {}/cur \; There's not much point using --showdots in cron, I would have thought, but it's probably useful for testing. To make sure your find command is right, you can do something like this: find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn --showdots --spam {}/cur" \; which will simply echo a list of commands that would get executed. Chris
Re: spam script
nope, that didn't have any effect either :( I've tried with -v option but that doesn't show me anything else going on either. Thanks for your suggestions though Sietse. Sietse van Zanen wrote: Just a thought, try escapeing the * find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/\* \; Maybe that helps. -Sietse ________ From: Nicholas Payne-Roberts [mailto:[EMAIL PROTECTED] Sent: Wed 12-Jul-06 15:12 To: Sietse van Zanen Subject: Re: spam script find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \; It just seems to execute without any errors but when you look in any of the cur directories, the files are still there: find /home/vpopmail/domains -name ".Junk E-mail" -exec ls -l {}/cur \; total 0 total 0 total 0 total 0 total 0 total 0 total 0 total 0 -rw-r--r-- 1 root root 0 Jul 12 16:09 test <-- a touch'd file i just placed into a cur directory to test the rm command. Sietse van Zanen wrote: I thought that was what you wanted. Otherwise I would expect the original command with * to be working well in removing the files in the ../cur directory. What's going wrong with that than? -Sietse From: Nicholas Payne-Roberts [mailto:[EMAIL PROTECTED] Sent: Wed 12-Jul-06 14:55 To: users@spamassassin.apache.org Subject: Re: spam script That deleted all of the cur directory within the .Junk E-mail directory. Sietse van Zanen wrote: Loose the * and do rm -rf (recursively deletes the directory) -Sietse From: Nicholas Payne-Roberts [mailto:[EMAIL PROTECTED] Sent: Wed 12-Jul-06 14:24 To: users@spamassassin.apache.org Subject: spam script I am now trying to figure out how to use find in a similar way to tidy up those Junk E-mail directories by deleting them after they have been used to learn from. This is what i've tried, but the rm command doesn't seem to like working with files within the /cur directory... find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \; If i try the above and omit the astrix, it complains about cur being a directory: rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/': Is a directory Thanks in advance for any suggestions :) Nick Chris Lear wrote: * Nicholas Payne-Roberts wrote (11/07/06 11:58): Does anybody know a good way to script sa-learn to daily check on junk e-mail folders? i'm currently trying the following line in a cron.daily script, but its throwing up an error: find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam cur {} \; Your --exec subcommand is the problem. The {} expands to the full path of the found file. It doesn't change directory. A version that might work is find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam {}/cur \; There's not much point using --showdots in cron, I would have thought, but it's probably useful for testing. To make sure your find command is right, you can do something like this: find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn --showdots --spam {}/cur" \; which will simply echo a list of commands that would get executed. Chris
Re: spam script
That deleted all of the cur directory within the .Junk E-mail directory. Sietse van Zanen wrote: Loose the * and do rm -rf (recursively deletes the directory) -Sietse From: Nicholas Payne-Roberts [mailto:[EMAIL PROTECTED] Sent: Wed 12-Jul-06 14:24 To: users@spamassassin.apache.org Subject: spam script I am now trying to figure out how to use find in a similar way to tidy up those Junk E-mail directories by deleting them after they have been used to learn from. This is what i've tried, but the rm command doesn't seem to like working with files within the /cur directory... find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \; If i try the above and omit the astrix, it complains about cur being a directory: rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/': Is a directory Thanks in advance for any suggestions :) Nick Chris Lear wrote: * Nicholas Payne-Roberts wrote (11/07/06 11:58): Does anybody know a good way to script sa-learn to daily check on junk e-mail folders? i'm currently trying the following line in a cron.daily script, but its throwing up an error: find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam cur {} \; Your --exec subcommand is the problem. The {} expands to the full path of the found file. It doesn't change directory. A version that might work is find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam {}/cur \; There's not much point using --showdots in cron, I would have thought, but it's probably useful for testing. To make sure your find command is right, you can do something like this: find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn --showdots --spam {}/cur" \; which will simply echo a list of commands that would get executed. Chris
spam script
I am now trying to figure out how to use find in a similar way to tidy up those Junk E-mail directories by deleting them after they have been used to learn from. This is what i've tried, but the rm command doesn't seem to like working with files within the /cur directory... find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \; If i try the above and omit the astrix, it complains about cur being a directory: rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/': Is a directory Thanks in advance for any suggestions :) Nick Chris Lear wrote: * Nicholas Payne-Roberts wrote (11/07/06 11:58): Does anybody know a good way to script sa-learn to daily check on junk e-mail folders? i'm currently trying the following line in a cron.daily script, but its throwing up an error: find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam cur {} \; Your --exec subcommand is the problem. The {} expands to the full path of the found file. It doesn't change directory. A version that might work is find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam {}/cur \; There's not much point using --showdots in cron, I would have thought, but it's probably useful for testing. To make sure your find command is right, you can do something like this: find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn --showdots --spam {}/cur" \; which will simply echo a list of commands that would get executed. Chris
Re: sa-learn script
Thats fantastic, thanks very much Chris! Chris Lear wrote: * Nicholas Payne-Roberts wrote (11/07/06 11:58): Does anybody know a good way to script sa-learn to daily check on junk e-mail folders? i'm currently trying the following line in a cron.daily script, but its throwing up an error: find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam cur {} \; Your --exec subcommand is the problem. The {} expands to the full path of the found file. It doesn't change directory. A version that might work is find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam {}/cur \; There's not much point using --showdots in cron, I would have thought, but it's probably useful for testing. To make sure your find command is right, you can do something like this: find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn --showdots --spam {}/cur" \; which will simply echo a list of commands that would get executed. Chris
sa-learn script
Does anybody know a good way to script sa-learn to daily check on junk e-mail folders? i'm currently trying the following line in a cron.daily script, but its throwing up an error: find /home/vpopmail/domains -name ".Junk E-mail" -exec sa-learn --showdots --spam cur {} \; Error: Learned tokens from 0 message(s) (0 message(s) examined) archive-iterator: unable to open cur: No such file or directory I'm using vpopmail as you can see, and each user has a .Junk E-mail folder under their Maildir. Many thanks, Nick Payne-Roberts