M
Mateusz Tybura
[Note: parts of this message were removed to make it a legal post.]
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
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