Have I appropriately professed my love for Ruby yet?


I used to play around with Ruby a lot. Here’s another script, where I was downloading fedora ISOs and giving myself feedback as to the progress of the operation (yes, I was in cygwin also).


#!/usr/bin/ruby
require 'net/ftp'
require 'fileutils'
ftp=Net::FTP.new("ftp.linux.ncsu.edu")
ftp.login("anonymous", "me@email.com")
FileUtils.chdir("/cygdrive/c/downloads/fedora")
files=ftp.chdir("pub/fedora/linux/core/3/i386/iso")

def mecallback()
print 'filename: ', (File.size($fileName) * 100.0 / $fileSize), "%n"
end

$fileName="FC3-i386-disc3.iso"
$fileSize=ftp.size($fileName)
print 'filename: ', $fileName, "n"
ftp.getbinaryfile($fileName, $fileName, 2**20) {
print 'filename: ', (File.size($fileName) * 100.0 / $fileSize), "%n"
}

ftp.close


Leave a Reply

%d bloggers like this: