#!/usr/bin/ruby require 'net/ftp' require 'uri' if ARGV.empty? puts "#$0 uri files ..." exit 1 end dest = URI.parse(ARGV.shift) Net::FTP.open(dest.host, dest.user, dest.password) {|ftp| ftp.debug_mode = true ftp.binary = true ftp.passive = false while /^-/ === ARGV.last case opt = ARGV.pop when /^-+p(asv)?/ then ftp.passive = true when /^-+a(scii)?/ then ftp.binary = false else puts "unknown flag (#{opt})" end end ftp.chdir dest.path for localfile in ARGV begin ftp.put(localfile) { |blk| $stdout.print '#' $stdout.flush } $stdout.print "\n" rescue Interrupt puts "abort" ftp.close end end }