Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Oct 2002 09:44:25 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: perl / ksh help
Message-ID:  <20021025084425.GB723@happy-idiot-talk.infracaninophi>
In-Reply-To: <Pine.LNX.4.44.0210250414470.537-100000@phenix.rootshell.be>
References:  <Pine.LNX.4.44.0210250414470.537-100000@phenix.rootshell.be>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Oct 25, 2002 at 04:43:15AM +0200, rootjrs wrote:

> I know some one has already done this and I need a little help.  I have 
> two identical directories on two seperate machines.  The files were 
> moved over fromm machine a to machine b.  Everything is working 
> properly on machine b but all of the permissions were lost.
> 
> I've done the following:
> 
> (machine a)# find ./ -ls -print > perm.list
> 
> Gave me the file listing and permisions
> 
> (machine a)# cat perm.list | awk '{print $4," ",$11}' > newperm.list
> 
> This removed garbage like date owners etc that I didn't need.
> 
> Now I'm stuck with a file that looks like this:
> 
> -rw-r--r--   ./data/dir/data/getme.bin.old
> -rw-rw-rw-   ./data/dir/data/stp.501
> drwxrwxrwx   ./data/dir/data/realgoodgold
> -rwsr-xr-x   ./data/dir/exe/help
> 
> At this point I'm thinking great, now all I need is to create a perl or 
> shell script that converts the -rw-r--r--, etc into some sort of numerical value and then 
> do soemthing like this
> 
> for
> chmod $1 $2
> done
> 
> .....using perl or ksh.  However I can't figure out how to do the 
> conversion correctly.  Please will one of you perl / ksh experts please 
> help me out.  

Instead of beating your brains out writing scripts to do this, simply
install ports/net/rsync.  Then synchronizing the file systems on the
two boxes is simple.  From the machine with the original copy of the
data:

    rsync -avx --delete /path/to/data/dir/ other.machine.com:/path/to/data/dir/

This will copy the data from the original filesystem to the second one
using the minimum amount of network traffic possible.  

Nb. the trailing slashes on those paths are important.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
                                                      Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021025084425.GB723>