I guess this depends on what you mean by "safe side". There are usually better ways to do this than using this old idiom. For remote machine copies think seriously about using rsync or scp. For local/nfs copies, you can consider using 'cp -r' which is supported by many of the newer OSs. Of course, you could write a perl solution using a CPAN module...

One problem I have with pipelines is that it is generally hard to check for and handle errors that occur. They are fine for quick and dirty things, but tend to break down if you really care about something working right (or handling errors right) each time.

For example, what happens if you don't have write access to the target directory or read access to all of the files in the source tree, or you run out of disk space, or you are writing to an soft-mounted NFS filesystem and you have a network problem? If you are using a single command (like 'cp -r), you can examine one error code. In your case it is harder (though not impossible) to check for errors.

Now if you are talking about security when you mention "safe side" the answer is "it depends". The only general thing I can think of offhand is that you need to be sure you are the only one able to write to the source tree or target directory during the actual copy operation. Of course there could be 100 other issues you have to worry about here (e.g. you are copying the files over a non-encrypted NFS mount between two machines and you decide you can't trust your network).

bluto


In reply to Re: chdir and security by bluto
in thread chdir and security by bronto

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.