For this situation use IO.popen with block wrapped in a Thread. -q option added for this working example:
file1 = "http://www.vim.org/scripts/download_script.php?src_id=7701"
file2 = "http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2"
threads = []
threads << Thread.new do
IO.popen("wget -q #{file1}"){ |io| io.read}
end
threads << Thread.new do
IO.popen("wget -q #{file2}"){ |io| io.read }
end
while true
sleep(2)
threads.each_with_index do |tr, index|
if tr.alive?
puts "Downloading in \##{index}"
else
puts "Downloaded in \##{index}"
threads[index] = Thread.new do
IO.popen("wget -q #{file1}"){ |io| io.read}
end
end
end
end