Type:
Class
Constants:
MDTM_REGEXP : /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/

This class implements the File Transfer Protocol. If you have used a command-line FTP program, and are familiar with the commands, you will be able to use this class easily. Some extra features are included to take advantage of Ruby's style and strengths.

Example

require 'net/ftp'

Example 1

ftp = Net::FTP.new('example.com')
ftp.login
files = ftp.chdir('pub/lang/ruby/contrib')
files = ftp.list('n*')
ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
ftp.close

Example 2

Net::FTP.open('example.com') do |ftp|
  ftp.login
  files = ftp.chdir('pub/lang/ruby/contrib')
  files = ftp.list('n*')
  ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
end

Major Methods

The following are the methods most likely to be useful to users:

acct

acct(account) Instance Public methods Sends the ACCT command.

2015-04-20 13:07:55
rename

rename(fromname, toname) Instance Public methods Renames a file on the server

2015-04-20 15:01:32
abort

abort() Instance Public methods Aborts the previous command (ABOR command).

2015-04-20 13:00:32
system

system() Instance Public methods Returns system information.

2015-04-20 15:47:34
connect

connect(host, port = FTP_PORT) Instance Public methods Establishes an

2015-04-20 13:25:58
list

list(*args) Instance Public methods Returns an array of file information in

2015-04-20 14:07:32
sendcmd

sendcmd(cmd) Instance Public methods Sends a command and returns the response

2015-04-20 15:20:45
closed?

closed?() Instance Public methods Returns true iff the connection

2015-04-20 13:20:50
getbinaryfile

getbinaryfile(remotefile, localfile = File.basename(remotefile), blocksize = DEFAULT_BLOCKSIZE) Instance Public methods

2015-04-20 13:50:01
help

help(arg = nil) Instance Public methods Issues the HELP command.

2015-04-20 14:05:36