develooper Front page | perl.beginners | Postings from February 2002

Re: How to copy and keep file permissions

Thread Previous | Thread Next
From:
Craig Eberly
Date:
February 20, 2002 09:17
Subject:
Re: How to copy and keep file permissions
Message ID:
3C73DA20.65535B6E@uu.net
Hmm, I've tried this but it doesn't seem to change the file permissions at
all on the backup file.  I checked into it, and my stat command or  $mode in
this case is equal to 33261.   Is that a normal output for the mode in the
stat command?  I'm on a Solaris 8 system.

Thanks,
Craig
(Sorry if the wording of this questions is horrible.   I'm just waking up)


> Here, this shows you the basics of retaining file permissions.
>
> #!/usr/bin/perl
> use warnings;
> use File::Copy;
> use strict;
> my $mode = (stat $ARGV[0])[2];
> copy( "$ARGV[0]", "$ARGV[0]\.bak" );
> chmod ($mode, "$ARGV[0]\.bak");
> print "Backup completed.\n";
> exit 0;
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About