Category: ruby

  • 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/rubyrequire ‘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)…

  • Ruby is so elegant

    This is a script to log in to a server via Telnet and run a single script remotely. require ‘net/telnet.rb’myserver.com = Net::Telnet::new("Host" => "myserver.com", "Timeout" => 30, "Prompt" => /[$%#] z/n)myserver.com.login("username", "password") { |c| print c }myserver.com.closemyserver.com.cmd("./check_missing.sh") { |c| print c }