You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Nicholas Payne-Roberts <ni...@payne-roberts.com> on 2006/07/12 14:24:56 UTC
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
Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
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
Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
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:nick@payne-roberts.com]
>> 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:nick@payne-roberts.com]
>>> 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:nick@payne-roberts.com]
>>>> 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
Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
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:nick@payne-roberts.com]
> 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:nick@payne-roberts.com]
>> 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:nick@payne-roberts.com]
>>> 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
Posted by Sietse van Zanen <si...@wizdom.nu>.
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:nick@payne-roberts.com]
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:nick@payne-roberts.com]
> 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
Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
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:nick@payne-roberts.com]
> 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
Posted by Sietse van Zanen <si...@wizdom.nu>.
Loose the * and do rm -rf (recursively deletes the directory)
-Sietse
________________________________
From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
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
Posted by "John D. Hardin" <jh...@impsec.org>.
On Wed, 12 Jul 2006, Nicholas Payne-Roberts wrote:
> 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.
Keep 'em. It simplifies retraining from scratch should you need to do
so and untraining if somebody misclassifies a message.
If you don't want sa-learn to have to wade through them, then move
them to a different directory.
If you want to use less disk space, then compress them.
--
John Hardin KA7OHZ ICQ#15735746 http://www.impsec.org/~jhardin/
jhardin@impsec.org FALaholic #11174 pgpk -a jhardin@impsec.org
key: 0xB8732E79 - 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
The first time I saw a bagpipe, I thought the player was torturing
an octopus. I was amazed they could scream so loudly.
-- cat_herder_5263 on Y! SCOX
-----------------------------------------------------------------------
12 days until The 37th anniversary of Apollo 11 landing on the Moon