Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
"be consistent"
 
PerlMonks  

How do I preserve file times when using Net::FTP?

( #61344=categorized question: print w/ replies, xml ) Need Help??
Contributed by javze on Feb 28, 2001 at 20:33 UTC
Q&A  > files


Description:

I'm using Net::FTP to download some files and I would like to preserve the times of the files I get from there. Ideas?

Answer: How do I change the modification time of a file?
contributed by merlyn

I believe if you wrap your request into an LWP::Simple mirror call instead (using an FTP URL), the mirror code correctly sets the time stamp, which means that there's some code in there somewhere to consistently understand the remote timestamp. Setting the timestamp locally is trivial: use the utime operator.

Answer: How do I change the modification time of a file?
contributed by fundflow

I had similar problem and addressed it via a script: savetime / loadtime. It will be helpful for you if you download from one of your own machines.

For your need, you will run it once on the FTP server to save the times and you run it localy to restore the times after the transfer.

Answer: How do I preserve file times when using Net::FTP?
contributed by Anonymous Monk

To accomplish this without using LWP you can do:

$mod_time = $ftp->mdtm($remote_file);
$ftp->get($remote_file,$local_file);
$resp = utime($mod_time,$mod_time,$local_file);
This should work on everything but FAT Win32.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (12)
    As of 2014-04-17 13:21 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (447 votes), past polls