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, 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).
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[0] == 33
raise FTPReplyError, resp if passwd.nil?
resp = sendcmd('PASS ' + passwd)
end
if resp[0] == 33
raise FTPReplyError, resp if acct.nil?
resp = sendcmd('ACCT ' + acct)
end
end
if resp[0] != 22
raise FTPReplyError, resp
end
@welcome = resp
send_type_command
@logged_in = true
end