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:

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
sendcmd

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

2015-04-20 15:20:45
dir

dir(*args) Instance Public methods Alias for:

2015-04-20 13:37:11
read_timeout=

read_timeout=(sec) Instance Public methods Setter for the #read_timeout attribute

2015-04-20 14:57:15
set_socket

set_socket(sock, get_greeting = true) Instance Public methods WRITEME or make

2015-04-20 15:26:33
delete

delete(filename) Instance Public methods Deletes a file on the server.

2015-04-20 13:32:29
close

close() Instance Public methods Closes the connection. Further operations are

2015-04-20 13:17:37
new

new(host = nil, user = nil, passwd = nil, acct = nil) Class Public methods Creates

2015-04-20 12:56:18
site

site(arg) Instance Public methods Issues a SITE command.

2015-04-20 15:27:32