Mitsuru Furukawa <furu(_at_)009(_dot_)com> writes:
I want to chmod a file right after finishing writing to it.
echo "<h1>END of WEB</h1>" >> $WEB/$FILE.html;
| chmod a+r $WEB/$FILE.html
This recipe works only about 50% of the time:-<
It fails with message WARNING: can't access.....
| sleep 5; chmod a+r $WEB/$FILE.html
but, did not improve.
Is there better way?
Fix the permissions once (outside of procmail), and then tell procmail
(using the UMASK variable) to use the correct umask for that recipe.
You also need to tell procmail that the action isn't going to be
reading the entire message that procmail is trying to feed to it, and
that procmail should _not_ consider this an error. (This is the source
of the "50%" troubles.) Thus the recipe needs the 'i' flag:
# set a less paranoid umask that allows everyone read access
# in case the file doesn't exist
UMASK = 022
* conditions here
|echo "<h1>END of WEB</h1>" >> $WEB/$FILE.html
UMASK = 077 # restore the paranoid umask
I'll note that the umask does *NOT* affect the permissions of a file
that already exists: that's what chmod is for. The umask only affects
the permissions of newly created files.