Copying files and retaining permissions query...

Hi there,

I’ve been writing a script to copy some files from a folder on Server A to a folder on Server B whilst retaining any file permissions. The files in question have been selected in the Finder.

I’ve tried a number a variations using the Finder, which is pretty slow, and then shell scripts which is a lot faster. The problem I’m having is that when I use the shell script version the file permissions are lost, I’m presuming it’s because of the method I’m using:-

do shell script ("cp " & quoted form of ("/Users/XXX/Desktop/" & (y as text)) & space & quoted form of "/Volumes/THIS-VOLUME/THIS-FOLDER/YYY/")

Please can someone point me in the right direction?

Thanks

Nick

Hi,

try the -p switch

[i]-p Cause cp to preserve the following attributes of each source file
in the copy: modification time, access time, file flags, file mode,
user ID, and group ID, as allowed by permissions. Access Control
Lists (ACLs) and Extended Attributes (EAs), including resource
forks, will also be preserved.

       If the user ID and group ID cannot be preserved, no error message
       is displayed and the exit value is not altered.

       If the source file has its set-user-ID bit on and the user ID can-
       not be preserved, the set-user-ID bit is not preserved in the
       copy's permissions.  If the source file has its set-group-ID bit on
       and the group ID cannot be preserved, the set-group-ID bit is not
       preserved in the copy's permissions.  If the source file has both
       its set-user-ID and set-group-ID bits on, and either the user ID or
       group ID cannot be preserved, neither the set-user-ID nor set-
       group-ID bits are preserved in the copy's permissions.[/i]

Hi Stefan,

Thanks for the help on preserving the attributes. I’ve tried using it like this:-

do shell script ("cp -p " & quoted form of "/Volumes/...

Unfortunately the copy parts works but then I get the error ‘cp: chflags: /users/fredbloggs/Desktop/this-file: Operation not permitted’

To test things I’ve been trying to copy the files to my desktop from the server. Am I using the -p correctly? If so I guess the error is due to permissions on my machine?

Do you have any ideas as to why I’m getting the error?

Thanks once again for your time.