Included Modules

Class/Module Index

Net::FTP

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.

Constants

Attributes

When true, all traffic to and from the server is written to
+$stdout+. Default: false.

last_response[R]

The server’s last response.

last_response_code[R]

The server’s last response code.

lastresp[R]

The server’s last response code.

open_timeout[RW]

Number of seconds to wait for the connection to open. Any number may be
used, including Floats for fractional seconds. If the FTP object cannot open a connection in this many
seconds, it raises a Net::OpenTimeout exception. The default value is
nil.

passive[RW]

When true, the connection is in passive mode. Default:
true.

read_timeout[R]

Number of seconds to wait for one block to be read (via one read(2) call).
Any number may be used, including Floats for fractional seconds. If the FTP object cannot read data in this many seconds, it
raises a Timeout::Error exception. The default value is 60 seconds.

Creates and returns a new FTP object. If a host
is given, a connection is made. Additionally, if the user is
given, the given user name, password, and (optionally) account are used to
log in. See login.

Establishes an FTP connection to host, optionally
overriding the default port. If the environment variable
SOCKS_SERVER is set, sets up the connection through a SOCKS
proxy. Raises an exception (typically Errno::ECONNREFUSED) if
the connection cannot be established.

Logs in to the remote host. The session must have been previously
connected. If user is the string “anonymous” and the
password is nil, “anonymous@” is used as a
password. If the acct parameter is not nil, an
FTP ACCT command is sent following the successful
login. Raises an exception on error (typically
Net::FTPPermError).

Returns an array of the entries of the directory specified by
pathname. Each entry has the facts (e.g., size, last
modification time, etc.) and the pathname. If a block is given, it iterates
through the listing. If pathname is omitted, the current
directory is assumed.

Puts the connection into binary (image) mode, issues the given command, and
fetches the data returned, passing it to the associated block in chunks of
blocksize characters. Note that cmd is a server
command (such as “RETR myfile”).

Puts the connection into ASCII (text) mode, issues the given command, and
passes the resulting data, one line at a time, to the associated block. If
no block is given, prints the lines. Note that cmd is a server
command (such as “RETR myfile”).

Puts the connection into binary (image) mode, issues the given server-side
command (such as “STOR myfile”), and sends the contents of the file named
file to the server. If the optional block is given, it also
passes it the data, in chunks of blocksize characters.

Puts the connection into ASCII (text) mode, issues the given server-side
command (such as “STOR myfile”), and sends the contents of the file named
file to the server, one line at a time. If the optional block
is given, it also passes it the lines.

# File net/ftp.rb, line 586defstorlines(cmd, file) # :yield: linesynchronizedowith_binary(false) doconn = transfercmd(cmd)
loopdobuf = file.getsbreakifbuf==nilifbuf[-2, 2] !=CRLFbuf = buf.chomp+CRLFendconn.write(buf)
yield(buf) ifblock_given?endconn.closevoidrespendendrescueErrno::EPIPE# EPIPE, in this case, means that the data connection was unexpectedly# terminated. Rather than just raising EPIPE to the caller, check the# response on the control connection. If getresp doesn't raise a more# appropriate exception, re-raise the original exception.getrespraiseend