# Mtime for ftp

**URL:** <https://www.ruby-forum.com/t/mtime-for-ftp/117729>\
**Category:** Ruby\
**Created:** [October 19, 2007, 7:25pm UTC](https://www.ruby-forum.com/t/mtime-for-ftp/117729 "2007-10-19T19:25:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [October 19, 2007, 7:25pm UTC](https://www.ruby-forum.com/t/mtime-for-ftp/117729/1 "2007-10-19T19:25:02Z")

</div>

Hi,  
I’d like to go to an ftp site and check the dates of available files  
there. (I only want today files.) I see that ftp, from ‘net/ftp’ has an  
mtime method. But, I can’t seem to get it to work. Here’s what I’ve  
tried.

…  
xmlfiles = ftp.list(’\*.xml’)  
xmlfiles.each do |xmlfile|  
puts xmlfile  
puts ftp.mtime(xmlfile)  
end  
…

I get something like this:

Exception: 500 ‘MDTM -rw-rw-r-- 1 bna staff 43945 Oct 19  
08:50 lobbyreg-20071010-160009.xml’: command not understood.

Just doing the “puts xmlfile” works fine, just not the mtime thing.

Thanks,  
Peter

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [October 22, 2007, 6:03pm UTC](https://www.ruby-forum.com/t/mtime-for-ftp/117729/2 "2007-10-22T18:03:02Z")

</div>

On Oct 19, 2007, at 10:25 , Peter B. wrote:

> puts xmlfile  
> puts ftp.mtime(xmlfile)  
> end  
> …
> 
> I get something like this:
> 
> Exception: 500 ‘MDTM -rw-rw-r-- 1 bna staff 43945 Oct 19  
> 08:50 lobbyreg-20071010-160009.xml’: command not understood.
> 
> Just doing the “puts xmlfile” works fine, just not the mtime thing.

I don’t think every server supports MDTM.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [October 23, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/mtime-for-ftp/117729/3 "2007-10-23T19:38:26Z")

</div>

On Oct 22, 2007, at 12:25 , Peter B. wrote:

> > > 08:50 lobbyreg-20071010-160009.xml’: command not understood.
> > > 
> > > Just doing the “puts xmlfile” works fine, just not the mtime thing.
> > 
> > I don’t think every server supports MDTM.
> 
> Thanks. I don’t even know what MDTM is. It’s obviously part of Ruby’s  
> ftp, though, isn’t it?

Actually, it looks like you’re not passing the filename, but are  
passing a bunch of file metadata along with the file’s name.

I presume MDTM is the command you send to the FTP server to get it to  
return the modification time, like GET.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [October 22, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/mtime-for-ftp/117729/4 "2007-10-22T21:25:43Z")

</div>

Eric H. wrote:

> On Oct 19, 2007, at 10:25 , Peter B. wrote:
> 
> > puts xmlfile  
> > puts ftp.mtime(xmlfile)  
> > end  
> > …
> > 
> > I get something like this:
> > 
> > Exception: 500 ‘MDTM -rw-rw-r-- 1 bna staff 43945 Oct 19  
> > 08:50 lobbyreg-20071010-160009.xml’: command not understood.
> > 
> > Just doing the “puts xmlfile” works fine, just not the mtime thing.
> 
> I don’t think every server supports MDTM.

Thanks. I don’t even know what MDTM is. It’s obviously part of Ruby’s  
ftp, though, isn’t it?
