# Problem with Net::FTP#mtime

**URL:** <https://www.ruby-forum.com/t/problem-with-net-ftp-mtime/102432>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/problem-with-net-ftp-mtime/102432 "2006-08-15T14:17:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/problem-with-net-ftp-mtime/102432/1 "2006-08-15T14:17:18Z")

</div>

Hi all,

Ruby 1.8.4  
Solaris 10, connecting to a Solaris 8 remote host.

I’ve got a code snippet like the one below. It connects fine, performs  
the  
chdir fine, performs the nlst fine, but chokes on mtime:

FTP.open(host, user, password) do |ftp|  
ftp.chdir(some\_dir)  
ftp.nlst.each{ |file|  
puts file # prints “audit17717447” fine  
puts ftp.mtime(file, true) # Boom! See below  
}  
end

Results:

/opt/csw/lib/ruby/1.8/net/ftp.rb:243:in `getresp': 500 'MDTM audit17717447': command not understood. (Net::FTPPermError) from /opt/csw/lib/ruby/1.8/net/ftp.rb:264:in`sendcmd’  
from /opt/csw/lib/ruby/1.8/monitor.rb:229:in `synchronize' from /opt/csw/lib/ruby/1.8/net/ftp.rb:262:in`sendcmd’  
from /opt/csw/lib/ruby/1.8/net/ftp.rb:767:in `mdtm' from /opt/csw/lib/ruby/1.8/net/ftp.rb:699:in`mtime’

Am I doing something wrong here? I don’t see anything like ‘MDTM’  
mentioned in  
my ftp man page. Or is it time to parse the long file name format  
manually?

Thanks,

Dan

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/problem-with-net-ftp-mtime/102432/2 "2006-08-15T14:17:19Z")

</div>

Daniel B. wrote:

> ftp.nlst.each{ |file|  
> from /opt/csw/lib/ruby/1.8/monitor.rb:229:in `synchronize' from /opt/csw/lib/ruby/1.8/net/ftp.rb:262:in`sendcmd’  
> from /opt/csw/lib/ruby/1.8/net/ftp.rb:767:in `mdtm' from /opt/csw/lib/ruby/1.8/net/ftp.rb:699:in`mtime’
> 
> Am I doing something wrong here? I don’t see anything like ‘MDTM’  
> mentioned in my ftp man page. Or is it time to parse the long file  
> name format manually?  
> I’ve had the same problem. Sometimes #mtime will work, sometimes not.  
> It seems to depend on the ftp server I’m going against. IIRC, I  
> couldn’t get it to work going against Windows2000 ftp services, so I  
> ended up parsing the long file name format myself.

Jamey

Confidentiality Notice: This email message, including any attachments,  
is for the sole use of the intended recipient(s) and may contain  
confidential and/or privileged information. If you are not the intended  
recipient(s), you are hereby notified that any dissemination,  
unauthorized review, use, disclosure or distribution of this email and  
any materials contained in any attachments is prohibited. If you receive  
this message in error, or are not the intended recipient(s), please  
immediately notify the sender by email and destroy all copies of the  
original message, including attachments.
