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() :
Please think again about whether you really want to use Perl for this problem.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"; }; };
When all you have is a hammer,
every problem looks like a nail.
In reply to RE: RE: Re: Checking permissions in multiple directories
by Corion
in thread Checking permissions in multiple directories
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |