Skip to content

Instantly share code, notes, and snippets.

@jolts
Created July 27, 2009 08:20
Show Gist options
  • Save jolts/156105 to your computer and use it in GitHub Desktop.
Save jolts/156105 to your computer and use it in GitHub Desktop.
#!/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