Downloading Files via FTP Using Ruby

This article will show you how to easily download files via FTP using Ruby.


Published on:October 5, 2013

Downloading files from an FTP server is quite easy using Ruby. Below is an example script that shows how to accomplish this.


require 'net/ftp'
ftp = Net::FTP.new
ftp.connect("myhostname.com",21)
ftp.login("myuser","my password")
ftp.chdir("/mydirectory")
ftp.passive = true
ftp.getbinaryfile("mysourcefile", "mydestfile")