[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

FTP File download

Brian Scott

12/6/2007 5:29:00 AM

Hello,

I am a Ruby Newbie

I need to login to a ftp server and download the newest file on the
server. I know the basics of Net::FTP but I can't figure out how to
download the newest file based on its time stamp.

Any Ideas

Thanks
--
Posted via http://www.ruby-....

2 Answers

Jano Svitok

12/6/2007 11:28:00 AM

0

On Dec 6, 2007 6:29 AM, Brian Scott <cuiguy@network32.net> wrote:
> Hello,
>
> I am a Ruby Newbie
>
> I need to login to a ftp server and download the newest file on the
> server. I know the basics of Net::FTP but I can't figure out how to
> download the newest file based on its time stamp.

FTP#list gives you list of files, possibly with timestamps, and
FTP#mtime gives you last modification time of a particular file.

RTFRDoc ;-) (e.g. http://ruby-doc...)

Robert Citek

12/6/2007 5:41:00 PM

0

On Dec 6, 2007 5:27 AM, Jano Svitok <jan.svitok@gmail.com> wrote:
> On Dec 6, 2007 6:29 AM, Brian Scott <cuiguy@network32.net> wrote:
> > Hello,
> >
> > I am a Ruby Newbie
> >
> > I need to login to a ftp server and download the newest file on the
> > server. I know the basics of Net::FTP but I can't figure out how to
> > download the newest file based on its time stamp.
>
> FTP#list gives you list of files, possibly with timestamps, and
> FTP#mtime gives you last modification time of a particular file.
>
> RTFRDoc ;-) (e.g. http://ruby-doc...)

Thanks for the link to the docs. Here's the one for NET::FTP:

http://ruby-doc...classes/Net/FTP.html

Unfortunately, I can't get the example to work for me. Specifically,
this worked:

$ ruby -le 'require "net/ftp" ; print "hello"'

but this does not, i.e. it just sits there:

$ ruby -le 'require "net/ftp" ; ftp = Net::FTP.new("ftp.netlab.co.jp")
; print "hello"'

So I changed to an ftp server that I know works, i.e. I can connect to
it via firefox:

$ ruby -le 'require "net/ftp" ; ftp =
Net::FTP.new("ftp.ncbi.nlm.nih.gov") ; print "hello"'

Still no dice. It's possible that this is because I'm behind a
firewall? ftp_proxy is set
to something like "http://proxy.foobar.com:1... and I've issued an
'export SOCKS_SERVER=$ftp_proxy', but ruby still doesn't work for me.

FYI:

$ ( set -x ; ruby -v ; cat /etc/issue.net )
+ ruby -v
ruby 1.8.5 (2006-08-25) [i486-linux]
+ cat /etc/issue.net
Ubuntu 7.04

Any pointers in the right direction appreciated.

Regards,
- Robert