Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to RE: RE: Re: Checking permissions in multiple directories by Corion
in thread Checking permissions in multiple directories by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-20 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found