Copy permission attributes 
Author Message
 Copy permission attributes

 I have used the File::Copy modules 'copy' function and it is losing the
execute permission from the files I have been coping. Am I missing
something obvious or is it up to me to set these afterwards ? (perl
5.005_3)

 Try it yourself (on a unix machine as opposed to windows) assume a file
called 'src' exists with the execute bit set, dst will be created
without the execute bit set.

 perl -e "File::Copy; copy(src,dst);"

 I have fixed my problem by adding roughly the following

 my $mode = (stat(src))[2];
 chmod($mode,dst);

--

Lyndon Homewood                    Software Engineer (Process Systems)

MathEngine PLC, Oxford Centre for Innovation, Mill St, Oxford, OX2 0JX
Tel: +44 1865 799416  Fax: +44 1865 799401   http://www.*-*-*.com/



Sun, 03 Nov 2002 03:00:00 GMT  
 Copy permission attributes
Quote:
>Am I missing
> something obvious or is it up to me to set these afterwards ?

yes and no.  on UNIX a new file's perms are created with the help of the
umask, (type in umask.  it will probably return something like 022.  i
forget exactly but 022 is or'ed with 777 to give the new file its perms.
you can adjust the umask but only to remove perms, not to add them, {except
for root of course}).  a mv will preserve the perms since the file's inode
is the same.  a cp creates a new file with new perms.

Quote:
>  my $mode = (stat(src))[2];
>  chmod($mode,dst);


maybe a slicker way to do it tho.


Mon, 04 Nov 2002 03:00:00 GMT  
 Copy permission attributes

Quote:

> I have used the File::Copy modules 'copy' function and it is losing
> the execute permission from the files I have been coping.

That should probably be fixed. Be sure to send the patch to perlbug! :-)

--
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



Mon, 04 Nov 2002 03:00:00 GMT  
 Copy permission attributes

Quote:


> > I have used the File::Copy modules 'copy' function and it is losing
> > the execute permission from the files I have been coping.

> That should probably be fixed. Be sure to send the patch to perlbug! :-)

Would it not be more logical to keep copy() as is and add this to
syscopy()?  Currently copy() and syscopy() on Unix are the same, but
on other platforms syscopy() tries to retain attributes.

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Tue, 05 Nov 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Invisible IB

2. Questions on Apollo 2.52

3. ANNOUNCE: Attribute::Protected, Attribute::Profiled, Attribute::Unimplemented

4. File::Copy does not preserve x attribute

5. Recursive file copy keeping date attributes

6. Load .BMP or .PCX or .GIF files fast.

7. Fixed-Point variables

8. Pascal Arrays Greater Than 64K

9. unwanted UNIX file permissions after using File::Copy::syscopy

10. Win32::Perms, copying permissions from subdirectories and files

11. Permissions, permissions, permissions....

12. How to set map attributes or file attributes under WinNT to run perl cgi

 

 
Powered by phpBB® Forum Software