Skip to content

Instantly share code, notes, and snippets.

@wicky-andrian
Forked from SunDi3yansyah/ftp.rb
Created November 13, 2018 11:37
Show Gist options
  • Save wicky-andrian/ddafde49f515e9b95ba2a8a7597b1e25 to your computer and use it in GitHub Desktop.
Save wicky-andrian/ddafde49f515e9b95ba2a8a7597b1e25 to your computer and use it in GitHub Desktop.
Download File on FTP Server with Ruby
# Ref: https://ruby-doc.org/stdlib-2.5.3/libdoc/net/ftp/rdoc/Net/FTP.html
require 'net/ftp'
Net::FTP.open('ftp.gnu.org') do |ftp|
ftp.login
ftp.chdir('gnu/wget')
nlst = ftp.nlst('*.tar.gz')
nlst.map {|file_name| ftp.gettextfile(file_name) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment