progromatic download of rpm file

J

Jedrin

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')
 
J

Jesús Gabriel y Galán

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|
=A0resp =3D http.get("/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-
release-0.3.6-1.el5.rf.x86_64.rpm")
=A0open("postgis.rpm", "wb") { |file|
=A0 =A0file.write(resp.body)
=A0 }
}



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 =3D "http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-relea=
se-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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top