Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by javze (Novice)
on Feb 28, 2001 at 20:33 UTC ( #61344=perlquestion: print w/replies, xml ) Need Help??

javze has asked for the wisdom of the Perl Monks concerning the following question:

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?

Originally posted as a Categorized Question.

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

Replies are listed 'Best First'.
Re: How do I change the modification time of a file?
by merlyn (Sage) on Feb 28, 2001 at 21:25 UTC
    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.
Re: How do I change the modification time of a file?
by fundflow (Chaplain) on Feb 28, 2001 at 21:51 UTC
    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.

Re: How do I preserve file times when using Net::FTP?
by Anonymous Monk on Jun 24, 2002 at 16:59 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://61344]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2021-05-14 11:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?