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

How to copy and keep file permissions

Thread Next
From:
Craig Eberly
Date:
February 16, 2002 13:00
Subject:
How to copy and keep file permissions
Message ID:
3C6EBFA6.E84045EB@uu.net
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
problem.

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]" );
#binmode(FILE);
#$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
ideas?

Thanks,
Craig



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