login(user = "anonymous", passwd = nil, acct = nil)
public
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).
Show source
def login(user = "anonymous", passwd = nil, acct = nil)
if user == "anonymous" and passwd == nil
passwd = "anonymous@"
end
resp = ""
synchronize do
resp = sendcmd('USER ' + user)
if resp.start_with?("3")
raise FTPReplyError, resp if passwd.nil?
resp = sendcmd('PASS ' + passwd)
end
if resp.start_with?("3")
raise FTPReplyError, resp if acct.nil?
resp = sendcmd('ACCT ' + acct)
end
end
if !resp.start_with?("2")
raise FTPReplyError, resp
end
@welcome = resp
send_type_command
@logged_in = true
end