Progromatic download of rpm file

not sure why neither of these ways to download an rpm from ruby don’t
work, but
if I use a web broswer on the same url there’s no problem …


require ‘net/http’

Net::HTTP.start(“apt.sw.be”) { |http|
resp = http.get("/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-
release-0.3.6-1.el5.rf.x86_64.rpm")
open(“postgis.rpm”, “wb”) { |file|
file.write(resp.body)
}
}

open(‘http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-
release-0.3.6-1.el5.rf.x86_64.rpm’)

On Wed, Oct 6, 2010 at 6:45 PM, Jedrin [email protected] wrote:

release-0.3.6-1.el5.rf.x86_64.rpm")
open(“postgis.rpm”, “wb”) { |file|
file.write(resp.body)
}
}

open(‘http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-
release-0.3.6-1.el5.rf.x86_64.rpm’)

This worked for me:

require ‘open-uri’

URL =
http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
File.open(“result.rpm”, “wb”) do |out|
out.write open(URL) {|in_file| in_file.read}
end

result.rpm ends up being a binary file of 16697 bytes.

Jesus.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs