View Single Post
  #2  
Old 27th September 2009, 04:15
lchvdlch lchvdlch is offline
Junior Member
 
Join Date: Sep 2009
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Default

I suggest you to use something like:

Code:
#!/bin/bash
KATALOG=/var/scripts
FILESPEC=*.sh
DIRPERM=700
FILEPERM=750
OWNER=user:group
CH_FSPEC=0
if [ -d $KATALOG ]
then
 find $KATALOG -type d | xargs chmod $DIRPERM
 if [ $CH_FSPEC -gt 0 ]
 then
  find $KATALOG -type f | xargs chmod $FILEPERM
 else
  find $KATALOG -type f | grep -v "$FILESPEC" | xargs chmod $FILEPERM
 fi
 chown -R $OWNER $KATALOG
 for SCRIPT in $KATALOG/$FILESPEC
 do
  if [ -x $SCRIPT ]
  then
   echo "Executing : $SCRIPT"
   . $SCRIPT
  fi
 done
else
 echo "ERROR! The directory doesn't exist."
 exit 1
fi
exit 0
I wouldn't like a cron script to change permissions. Giving execution permissions on the fly, seems pretty dangerous to me.
Reply With Quote