Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

RE: RE: Re: Checking permissions in multiple directories

by Corion (Patriarch)
on Jun 04, 2000 at 14:11 UTC ( [id://16282]=note: print w/replies, xml ) Need Help??


in reply to RE: Re: Checking permissions in multiple directories
in thread Checking permissions in multiple directories

File::Find already descends down through all subdirectories, sorry if I didn't mention that.

But it really seems to me as if a tool such as rsync or a simpler solution using tar cfz transfer.tgz would do what you want in a much better way, since rsync can keep two directory branches synchronized in all ways without transferring all files and tar works more or less like cp. Please either restate your problem or think about using a readymade tool.

The necessary modifications for my above script to tell you if a file is missing on machine B would be in the routine checkpermissions() :

sub checkpermissions { my( $directory ) = @_; my ( $targetdir = $directory ) =~ s!^$sourcedir!$targetdir!; # now we check first of the item in $targetdir exists : if (-f $targetdir || -d $targetdir) { my ($perm_s, $perm_t); my @statresults; # This could be more optimized, but ... @statresults = stat( $directory ); $perm_s = @statresults[2]; @statresults = stat( $targetdir ); $perm_t = @statresults[2]; if ($perm_s != $perm_t ) { print "$targetdir has wrong permissions."; chmod $perm_s, $targetdir or die "Couldn't update the permissi +ons for $targetdir : $!\n"; }; } else { # I assume you don't have links or other stuff. # If you have symlinks etc., use rsync or tar # I cheat and call cp for copying all stuff recursively system "cp", "-R", "$directory", "$targetdir"; }; };
Please think again about whether you really want to use Perl for this problem.

When all you have is a hammer,
every problem looks like a nail.

Replies are listed 'Best First'.
RE: RE: RE: Re: Checking permissions in multiple directories
by Anonymous Monk on Jun 05, 2000 at 17:52 UTC
    I tired using the stat function, but the when I do a $temp = $stats2; i get a number like 33261 then the chmod craps out. Am I doing something wrong?

      Since you aren't even telling, what goes wrong, I can't help you here. Maybe you don't have the right permissions on the target machine or the target directory...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://16282]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (8)
As of 2024-04-24 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found