Subject: Simple Scripting ? (Is directory empty?)
From: Adam Price (Adam@oldchildrensbooks.com)
Date: Mon Dec 13 1999 - 10:05:10 MST
The following script is supposed to do the following:
1. Look at the directory /var/qmail/alias/pppdir/new/
2. If it is nonempty, run the maildirsmtp program to empty it
3. Otherwise say there was no mail to send.
Instead, the initial test ALWAYS proves true. This results in lots of
"directory was empty messages. I have tried various flags, (-s, -f,
-N) none of them work (and from reading the man pages, they shouldn't)
I know how I could accomplish this using a temporary file, and cat'ing ls
into it, but that seem like overkill.
How do I ask bash if a directory is empty?
#!/bin/bash
if test -s /var/qmail/alias/pppdir/new/ <<----HERE's the trouble
then
#outgoing mail exists - flush it
/usr/local/bin/maildirsmtp ~alias/pppdir alias-ppp- 207.234.184.12
echo "sending mail"
else
# #Let us know the file is empty
echo "No mail to send"
exit
fi
-- adam@oldchildrensbooks.comOne way to get high blood pressure is to go mountain climbing over molehills. -- Earl Wilson
This archive was generated by hypermail 2a24 : Sun Jan 02 2000 - 12:12:58 MST