Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
SFTP SymLink - Create Symbolic Link on Server
See more SFTP Examples
Demonstrates how to create a symbolic link on the SFTP server.Chilkat Pascal (Lazarus/Delphi) Downloads
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.SFtp;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
sftp: TSFtp;
begin
success := False;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
sftp := TSFtp.Create;
// Pass a domain or IP address..
success := sftp.Connect('my-sftp-server.com',22);
if (success = True) then
begin
success := sftp.AuthenticatePw('mySFtpLogin','mySFtpPassword');
end;
if (success = True) then
begin
success := sftp.InitializeSftp();
end;
if (success <> True) then
begin
WriteLn(sftp.LastErrorText);
Exit;
end;
// Create a symbolic link on the server.
// We'll create a link in our HOME directory named "sshd_config"
// which points to the file /etc/ssh/sshd_config.
success := sftp.SymLink('/etc/ssh/sshd_config','sshd_config');
if (success <> True) then
begin
WriteLn(sftp.LastErrorText);
Exit;
end;
WriteLn('Successfully created symbolic link.');
sftp.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.