Answer the question
In order to leave comments, you need to log in
RUBY - FTP File Upload, Regular Expression Pattern?
Hello everyone, there is a script that connects to FTP and pulls a specific file, how to write a regular expression so that it pulls a file according to a pattern - instead of a file date, you need a pattern:
ftp = Net::FTP.new('x.x.x.x')
ftp.login('ololo', 'ololo')
files = ftp.chdir('/num')
ftp.getbinaryfile('Report_2017-02-09_15-20-30.csv', '/home/1.csv', 1024)
ftp.close
Answer the question
In order to leave comments, you need to log in
Decided this way
files1 = ftp.nlst('Report*')
report_name = Time.now.strftime("Report_%d.%m.%Y_%H.csv")
files1.each do |file|
ftp.getbinaryfile( file , "/home/#{report_name}", 1024)
end
get a list of files using ls, filter it, upload each file separately
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question