From: Mateusz Tybura Date: 2008-07-31T02:30:48+09:00 Subject: My simple downloader doesn't work ------=_Part_62729_12573818.1217439086726 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, I'm learning Ruby for some time. Today I started to write simple code which will download specified files from specified servers but it doesn't work. It always showing me error 500 when code is going to download file. This is code: require 'net/ftp' require 'net/http' class Get def initialize(resource) if resource=~/http:\/\/|ftp:\/\// @resource=resource @status=0 @type = resource[0..1].to_s end end def get case (@type) when "ht" @sock = Net.HTTP.new(@resource) @sock.getbinaryfile("index.html",1024) when "ft" index = (@resource[6..-1].index("/")+5) last = (@resource.size - @resource.reverse.index("/")-1) ftp = Net::FTP.new(@resource[6..index]) ftp.login ftp.chdir(@resource[(index+2)..last]) ftp.get(@resource[(last+1)..-1] , @resource[(last+1)..-1]) ftp.close end end end get = Get.new("ftp://sunsite.icm.edu.pl/pub/Linux/slackware/ slackware-12.0/CHECKSUMS.md5.asc") get.get -- My own blog (in polish) : wujciol.yoyo.pl ------=_Part_62729_12573818.1217439086726--