ruby socketのftp


socketのftp応用と学習

require 'net/ftp'

begin
  ftp = Net::FTP.new()
  ftp.connect("localhost", 221)
  ftp.login("******", "******")
  #1.Download from server
  server_files = ftp.chdir('/')
  #  a         
  server_files = ftp.list('a*')
  puts server_files
  ftp.gettextfile('a.txt', 'a.log')
  
  #2.Upload   10        
  local_files = `find . -mmin 10`
  puts local_files
  for file in local_files
    ftp.put(file, file)
  end
  
rescue Exception => ex
  puts ex
ensure
  ftp.close
end