10-line Ruby FTP client

An example of why I like Ruby. This could be shortened further.

#!/usr/bin/ruby
 
require 'net/ftp'
 
ftp = Net::FTP.new(*ARGV)
 
while ! ftp.closed? do
    begin
        puts ftp.send(* STDIN.gets.strip.split(/\s+/))
    rescue
        puts "Command failed, oops."
    end
end
Tags:

Leave a Reply

You can use these tags in comments (Note: HTML is automatically escaped inside <pre> tags, nowhere else, so if you post source code, put it in <pre>):

<pre lang="some_programming_language"> 
<em>
<strong>
<a href="url">

NOTE: Comments are automatically spam-filtered. If your comment fails to appear, it was likely munched by the filter. Try not to link-spam or post anything that looks like it was typed by a robot.