Solved

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

Posted on 1998-09-10
2
172 Views
Last Modified: 2010-03-05
null
0
Comment
Question by:theconripper
2 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 100 total points
ID: 1204819
Sometimes, it pays to remember that unix is a system of small
tools... (and remember, there are 3,756 ways to do anything)

1.) Make a list of files where -M b/$file < -M c/$file
2.) [Make sure that the directory /a/c exists]
3.) system("cd /a/b; tar cf - * | (cd /a/c; tar xfBp -)");
4.) [Make sure that the directories above are either absolute, or you
    KNOW where you are]
5.) Apply the "extra html" code to each of the files in /a/c where the
    file is in the list of files created in step 1.

Hmmmm, no lstat, no rmtree, so easy :)
0
 

Author Comment

by:theconripper
ID: 1204820
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now