Scott,

> At 05:08 PM 9/23/2002 -0700, you wrote:
> >   ls -R | grep ":$" | sed 's#:$##' | awk '{print "\""$0"\""}' | xargs
> > chmod g+s
>
> Could I use something like this to set the proper ownership of a directory as
> well?
>
> I have copied all the user accounts from the BSDI machine to the Mandrake
> box, then I used a shell script to set the proper ownership of the directories,
> but I need to go in and set the sub directories.  Here is the base script I am
> working off of, but I don't think it likes the -R option.
>
> grep /home/ /home/scott/homedirpass | awk -F: '{ print $1 " " $4 " " $6
> ; }' \
>    | while read pwuser pwgid pwhome ; do
>      [ -d $pwhome ] || ( chown $pwuser:$pwgid $pwhome )
> done
>
> homedirpass is a copy of the Linux passwd file after I ran the script to
> convert the accounts to the new machine.

For ownership, it is much simpler to use the -R option

        chown -R owner.group directory

For file permission, that gets trickier because directories and
executables need the 'x' bit set. But for regular files, use
        chmod -R 640 directory
and then fix directories by using
        find directory -type d -exec chmod 750 {} \;

For your example, I think this will work for you
        grep /home/ /home/scott/homedirpass \
                | awk -F: '{ print $1 " " $4; }' \
                | while read pwuser pwgid ; do \
                        [ -d ~$pwuser ] || ( chown -R $pwuser.$pwgid ~$pwuser ) \
                  done


Thanks... Dan.



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to