Re: Saving permissions on files/folders (perl)
From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 11/17/04
- Next message: Andrew Falanga: "Re: KSH question on variables and relation to the exec command"
- Previous message: Dana French: "Re: mq"
- In reply to: Gnarlodious: "Re: Saving permissions on files/folders (perl)"
- Next in thread: Kevin Collins: "Re: Saving permissions on files/folders (perl)"
- Reply: Kevin Collins: "Re: Saving permissions on files/folders (perl)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 17 Nov 2004 15:54:57 +0000
2004-11-17, 15:28(+00), Gnarlodious:
> Entity Stephane CHAZELAS spoke thus:
>
>> using perl may be the best and most portable solution.
> It seems like it, for OSX
>
>> perl -MFile::Find -l0e '
>> $,=$\;
>> find sub {
>> @s=lstat($_);print ($File::Find::name,@s[2,4,5]) unless -l _;
>> }, "."' > /some/file
>
> OK, good. I don't understand perl, but the file I get looks like this:
>
> /Network/AFP/MountedDisks3318850180/Network/AFP/MountServer3318850180/Networ
> k/AFP/Ping Manhattan3326150180
>
> etc.
> I don't see any delimiters in this data, which may be why the Restore script
> errors.
They are delimited by NUL characters. A cat -vte should show
them as ^@.
>> Then, to restore:
>>
>> perl -0 -le '
>> while ($f=<>,$m=<> & 07777,$u=<>,$g=<>) {
>> chown $u, $g, $f
>> chmod $m, $f
>> }' < /some/file
>
> syntax error at -e line 4, near "$f
> chmod"
> Execution of -e aborted due to compilation errors.
This looks like a quoting problem of your shell. Are you using
csh or tcsh by any chance?
If you have problem with you shell, try putting the above
command in a file:
while ($f=<>,$m=<> & 07777,$u=<>,$g=<>) {
chown $u, $g, $f
chmod $m, $f
}
Then run perl -l0 the-file.pl < /some/file
>
> How would the first script insert a newLine after each entry (say, ascii 13)
> and a space between path and permission set?
[...]
newLine and space are valid characters in a filename so should
not be used to delimit file names. That's why I used the NUL
character.
-- Stephane
- Next message: Andrew Falanga: "Re: KSH question on variables and relation to the exec command"
- Previous message: Dana French: "Re: mq"
- In reply to: Gnarlodious: "Re: Saving permissions on files/folders (perl)"
- Next in thread: Kevin Collins: "Re: Saving permissions on files/folders (perl)"
- Reply: Kevin Collins: "Re: Saving permissions on files/folders (perl)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|