Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

Provide an FTP ACCT Account Identifier

See more FTP Examples

Demonstrates the Account property, which supplies the value for the FTP ACCT command sent after USER/PASS when a server requests it.

Background: ACCT is a vestige of early FTP, where an account identifier could be required in addition to the username and password — think mainframe billing codes or storage-group selection. It is very rarely needed today; almost every modern server authenticates with USER and PASS alone. Set this only when connecting to a legacy host that explicitly asks for account information after login.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.Ftp2;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  ftp: TFtp2;

begin
  success := False;

  ftp := TFtp2.Create;

  ftp.Hostname := 'ftp.example.com';
  ftp.Username := 'myFtpLogin';

  //  Normally you would not hard-code the password in source.  You should instead obtain it
  //  from an interactive prompt, environment variable, or a secrets vault.
  ftp.Password := 'myPassword';

  //  Account supplies the value for the FTP ACCT command, sent after USER/PASS when a server
  //  requests it.  This is very rarely needed today -- almost all modern servers use only USER and
  //  PASS -- but some legacy hosts require an additional account identifier.
  ftp.Account := 'myAccountId';

  success := ftp.Connect();
  if (success = False) then
    begin
      WriteLn(ftp.LastErrorText);
      Exit;
    end;

  WriteLn('Logged in (ACCT provided if the server requested it).');

  success := ftp.Disconnect();
  if (success = False) then
    begin
      WriteLn(ftp.LastErrorText);
      Exit;
    end;


  ftp.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.