1 |
Yeah, running sa-learn on an empty directory is fine, but it bugs me that when I then run |
2 |
rm on the contents of that directory, I get an error message. I know it doesn't hurt |
3 |
anything... it just bugs me. I thought it would be trivial to put the calls to "sa-learn" |
4 |
and "rm" in an if statement, but I guess I was wrong. |
5 |
|
6 |
b |
7 |
|
8 |
|
9 |
Christian Bricart wrote: |
10 |
> Ben Munat schrieb: |
11 |
> |
12 |
>> Argh. I've been trying to come up with what should be a simple bash |
13 |
>> script, but I just can't seem to get it right. |
14 |
>> |
15 |
>> I'm trying to fix up my cron script that runs sa-learn. I want it to |
16 |
>> check to see if there's actually any mails in the directory before |
17 |
>> running "sa-learn <my options> <my missed spam dir>" and then "rm <my |
18 |
>> missed spam dir>/*". |
19 |
> |
20 |
> |
21 |
> Actually, this is not a valid answer to your question - but as in the |
22 |
> "Hitchhkers Guide through the Galaxy": "Maybe your question has been all |
23 |
> wrong" ;-) |
24 |
> |
25 |
> Why do you want to check if the directioy is empty at all? Just call |
26 |
> "sa-learn" either in loop on every file in the directory. If it's emty |
27 |
> it's not executed at all. |
28 |
> On the other hand, you can call "sa-learn" on an empty directory and |
29 |
> you'll get "Learned from 0 messages". |
30 |
> |
31 |
> find /the/path/to/your/directory/ -type f -print0 | xargs -0 \ |
32 |
> sa-learn <your options> |
33 |
> |
34 |
>> |
35 |
>> I've gone in circles with using the "-e" test ("if [ -e $mydir'/*' ]") |
36 |
>> and just command success ("if `ls $mydirwithslashstar`", etc.) and I |
37 |
>> can't seem to get it right. What's the simplest way to just test if a |
38 |
>> directory is empty? |
39 |
> |
40 |
> |
41 |
> that would be something like: |
42 |
> |
43 |
> if [ `ls -l /path/to/directory | wc -l` -eq 0 ]; then |
44 |
> ... |
45 |
> fi |
46 |
> |
47 |
> (not tested though) |
48 |
> |
49 |
> Christian |
50 |
> |
51 |
> -- |
52 |
> gentoo-server@g.o mailing list |
53 |
> |
54 |
-- |
55 |
gentoo-server@g.o mailing list |