Created
July 27, 2009 08:20
-
-
Save jolts/156105 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
abort 'ang map baka' if ARGV.empty? | |
%w[net/ftp].each {|l| require l} | |
conf = { | |
:host => '127.0.0.1', | |
:user => 'jolts', | |
:pass => 'test', | |
:rdir => '.' | |
} | |
ftp = Net::FTP.new conf[:host] | |
ftp.login conf[:user], conf[:pass] | |
ftp.chdir '/' | |
puts ["\n"] << ftp.dir << ["\n"] | |
ARGV.each do |file| | |
filesize, completedsize, oldpercent = File.size(file).to_f, 0, 0 | |
ftp.put file, File.basename(file) do |data| | |
completedsize += data.size | |
percent = (completedsize / filesize) * 100 | |
increment = percent - oldpercent | |
oldpercent = percent | |
end | |
end | |
ftp.close | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment