class Net::FTP
Public Instance Methods
login(user = "anonymous", passwd = nil, acct = nil)
click to toggle source
Logs in to the remote host. The session must have been previously connected.
If user
is nil, Net::Netrc#locate is used to lookup login
information based on the host name supplied when the connection was
established.
If user
is the string “anonymous” and the
password
is nil, a password of user@host is synthesized. 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).
Example:
require 'net/ftp-netrc' # (brings in net/ftp and net/netrc) ftp = Net::FTP.new('myhost') ftp.login(nil) ftp.last_response => 230 User myuser logged in.
# File lib/net/ftp-netrc.rb, line 57 def login(user = "anonymous", passwd = nil, acct = nil) if user.nil? rc = Net::Netrc.locate(@host) if rc user = rc.login passwd = rc.password acct = rc.account else user = '' passwd = '' end end orig_login(user, passwd, acct) end
Also aliased as: orig_login