Link to home
Start Free TrialLog in
Avatar of theconripper
theconripper

asked on

Replicating Directories,Files. Symbolic links, lstat(), file permissions.

null
ASKER CERTIFIED SOLUTION
Avatar of b2pi
b2pi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of theconripper
theconripper

ASKER

Thank you for the quick response. I found the answer to be very similar to the logic I am already trying to implement.. so it's not all that useful.  Another point I didn't mention.. maybe implied.. was that /b/ will constantly be changing... so intitially there will be a large copy/rip of files.. followed by hourly "updates."

Scenario 1 (implement b2pi's way):  I can make the file list for file on /b/ that are newer than /c/.  The  system("cd /a/b; tar cf - * | (cd /a/c; tar xfBp -)"); command seems to tar everthing in the /b/ directory but that's not what we want if we go this route.  We would somehow want to tar only the files found.. I'm not sure this command does this.  Also... say a directory on 'b' is no longer used... I would need to rmtree() on /c/ to remove this dir.   I assume the "system" command above (if modified for the filelist) would recreate permissions and symbolic links.. am I right?

Scenario 2 (my original way): Questions NOT answered. 1) How do I tell if one of the newer files to be copied from /b/ to /c/ is a compiled binary (in which case I don't want to rip it)?  2)What does the number for mode (returned by lstat()) mean/ translate into with repect to unix permissions ie. 644/755/etc?   I also implemented symbolic links below (could you look and see if there might be a case/logic I'm missing.. it seems to work).
if (-l $Bfile)  {
        my ($Bfilename) = readlink($Bfile);  #the link seems to be relativized
        symlink($Bilename,$Cfile);             #Cfile is same file with modified path ex./b/g/file /c/g/file
        print "symlink of $Bfile to $Bfilename\n";
    }

AGAIN, thank you for your time and help.
Robert Duffy