develooper Front page | perl.beginners | Postings from February 2002

Time conflict using utime

From:
Student of Perl
Date:
February 12, 2002 16:29
Subject:
Time conflict using utime
Message ID:
20020213003041.9302.qmail@mailFA5.rediffmail.com

I have used Net::FTP for ftp coding 
in my script.

my problem is related to file modification
time. I use

$remote_date=$ftp->mdtm($remote_file);

#get remote_file to local disk
$ftp->get($remote_file); 

#and then set its date to that of remote file's date
utime $remote_date,$remote_date,$remote_file 

please note that in the 2nd statement $remote_file is now stored as locally hence here(in 2nd statement)the name $remote_file actually refers to the downloaded copy of the remote file.

So my purpose is to download the file and set its
modification time to that of remote file. The problem
is that taken the complete epoch number that
$ftp->mdtm() returns ; the last digit seems to be
increased by 1 in local epoch number ; this I came to
know when I checked the number returned by 
(stat $filename)[9]  function. So why there is difference
of 1 number between these 2 digits? I am calling
utime function after $ftp->get() function ; so that
means I change modification date after that file
has been created locally(or say downloaded). I want
the dates to be exactly same for local and remote
copy. I would have programmatically increased the
number by 1 ; but that assumption I dont think is safe.
So how to overcome this problem?

Thanks
-Jim 




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About