Revision: 42383
Updated Code
at March 4, 2011 04:05 by zalary
Updated Code
require 'net/ftp' require 'fileutils' include FileUtils #creates dir cd( "/Users/user/Folder/" ) dirc = Time.now.strftime("%Y%B%d") Dir.mkdir( dirc , 0700 ) cd( "/Users/user/Folder/" + dirc) ftp = Net::FTP.new('ftp.example.com') # run the script like # ruby ftp.rb username password ftp.login(user=ARGV[0], ARGV[1]) files = ftp.chdir('/OUTGOING') files = ftp.nlst('*') puts "File list obtained... #{files}" files.each do |fname| puts "Downloading file #{fname}" ftp.getbinaryfile(fname, fname) # uncomment the next two lines if you want to delete the files after download #puts "Deleting file #{fname}" #ftp.delete(fname) end ftp.close
Revision: 42382
Updated Code
at March 4, 2011 03:59 by zalary
Updated Code
require 'net/ftp' require 'fileutils' include FileUtils #creates dir cd( "/Users/zalary/Documents/DellReturns/" ) dirc = Time.now.strftime("%Y%B%d") Dir.mkdir( dirc , 0700 ) cd( "/Users/zalary/Documents/DellReturns/" + dirc) ftp = Net::FTP.new('ftp.example.com') ftp.login(user=ARGV[0], ARGV[1]) files = ftp.chdir('/OUTGOING') files = ftp.nlst('*') puts "File list obtained... #{files}" files.each do |fname| puts "Downloading file #{fname}" ftp.getbinaryfile(fname, fname) #puts "Deleting file #{fname}" #ftp.delete(fname) end ftp.close
Revision: 42381
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 4, 2011 03:58 by zalary
Initial Code
require 'net/ftp' require 'fileutils' include FileUtils #creates dir cd( "/Users/zalary/Documents/DellReturns/" ) dirc = Time.now.strftime("%Y%B%d") Dir.mkdir( dirc , 0700 ) cd( "/Users/zalary/Documents/DellReturns/" + dirc) ftp = Net::FTP.new('ftp.e-dialog.com') ftp.login(user=ARGV[0], ARGV[1]) files = ftp.chdir('/Active_Prospect/OUTGOING') files = ftp.nlst('*') puts "File list obtained... #{files}" files.each do |fname| puts "Downloading file #{fname}" ftp.getbinaryfile(fname, fname) #puts "Deleting file #{fname}" #ftp.delete(fname) end ftp.close
Initial URL
Initial Description
Initial Title
Download from FTP into a dated location
Initial Tags
Initial Language
Ruby