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

How to copy and keep file permissions

Thread Next
Craig Eberly
February 16, 2002 13:00
How to copy and keep file permissions
Message ID:
Hey, any help would be appreciated.
I just wanted to make a simple backup script to backup any file i
specified quickly.. and eventually let it accept options and whatnot for
directories, but right now, I'm just trying to get it to keep the file
permissions of the original file.  I'm using File::Copy for the
copying,  and I thought Digest::MD5 would work for the permissions

This is what i have:

#!/usr/local/bin/perl -w
use File::Copy;
#use Digest::MD5 qw(md5_hex);
use strict;
#open (FILE, "$ARGV[0]" );
#$ARGV[0] = Digest::MD5->new->addfile(*FILE)->hexdigest();
#close (FILE);
copy( "$ARGV[0]", "$ARGV[0]\.bak" );
print "Backup completed.\n";
exit 0;

The backup itself works like this,  but the # lines are what i was
trying to do to keep the file permissions.  This not only doesnt work,
but it causes the backup process to break as well.  Anyone have any


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About