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

1
require 'net/ftp'

Example 1

1
2
3
4
5
6
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

1
2
3
4
5
6
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:

sendcmd
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
help
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
delete
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
closed?
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
read_timeout=
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
status
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

status() Instance Public methods Returns the status (STAT command).

2025-01-10 15:47:30
dir
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

dir(*args) Instance Public methods Alias for:

2025-01-10 15:47:30
close
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
new
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

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

2025-01-10 15:47:30
size
  • References/Ruby on Rails/Ruby/Classes/Net/Net::FTP

size(filename) Instance Public methods Returns the size of the given (remote)

2025-01-10 15:47:30