Guest User

Untitled

a guest
May 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #!/usr/bin/env ruby19
  2. # encoding: utf-8
  3.  
  4. require 'net/ftp'
  5.  
  6. module RuFTP
  7. extend self
  8. Hostname = ''
  9.  
  10. def upload(args = ARGV)
  11. puts 'Files to upload:'
  12. args.each { |file| puts "> #{File.expand_path(file)}" }
  13.  
  14. @myftp = Net::FTP.new(Hostname)
  15. authenticate
  16.  
  17. print "Enter remote directory ('/' for current):\n> "
  18. @myftp.chdir($stdin.gets.chomp.to_s)
  19.  
  20. args.each do |file|
  21. puts "Uploading #{File.basename(file)}"
  22. @myftp.put(file, File.basename(file))
  23. end
  24. @myftp.close
  25. end
  26.  
  27. private
  28.  
  29. def authenticate
  30. _username = ''
  31. _password = ''
  32.  
  33. @myftp.login(user = _username, passwd = _password)
  34. end
  35. end
  36.  
  37. RuFTP.upload if $0 == __FILE__
Add Comment
Please, Sign In to add comment