Re: Unable to read timestamp for remote files



Alok Nath wrote:
When I try to retrieve the timestamp from a ftp folder I get
this error message :
>> Can't call method "mtime" on an undefined value at func.pl
line 69

but the same works in my local machine.

Of course it does. stat() looks for a file on your local machine.


My motive is to read the timestamp for each files in the remote folder.

Can somebody point out what is wrong exactly

What's wrong is that you're calling stat() on a filename that doesn't
exist on your local system. stat() has no way of knowing that the
filename you passed to it is actually representing a file on an FTP
server to which you happen to have an open connection.

or any alternative ??

Did you consider reading the documentation for the module you're using?

perldoc Net::FTP
<snip>
mdtm ( FILE )

Returns the modification time of the given file
<snip>


foreach ($ftp->ls($ftpDir)) {
print "file = $_\n" ;

$file_date = ctime(stat($_)->mtime);

my $file_date = $ftp->mdtm($_);

print "file $file updated at $file_date\n";
}
}

Paul Lalli

.



Relevant Pages

  • Re: How do you modify RMS file attributes when using ofstream I/O ?
    ... ** Template program to set RMS LRL attributes for RMS files. ... int set_lrl (char *filename, int lrl) ... if (!(stat&1)) return stat; ...
    (comp.os.vms)
  • Re: listing a huge amount of file on one file system
    ... to lstat() every file every symlink!) in order to ... than a simple linear list, ... it finds the filename, which may be anywhere in the listing). ...
    (RedHat)
  • Re: files
    ... ashu wrote: ... i can make program to accpet filename from command line and open it ... you can save yourself a lot of trouble by doing it in perl: ... As for stat etc: ...
    (uk.comp.os.linux)
  • Re: "ls" cant display octal permissions ?!?!
    ... names" - but that's for the uid and gid but not for the file permissions. ... or GNU stat: ... stat -c %a FILENAME ...
    (comp.unix.shell)
  • Re: UTF-8 and case-insensitivity
    ... Currently dnotify doesn't give you the filename that is being ... so that on a dnotify event you do a fcntlto ... just because our code is so messy that sometimes we do a stat() call ... and fixing them. ...
    (Linux-Kernel)