Sample code for 30+ languages & platforms
Visual FoxPro

SFTP ReadLink - Get the Target of a Symbolic Link on the Server

See more SFTP Examples

Demonstrates how to retrieve the target of a symbolic link on the SFTP server.

Note: This example requires Chilkat v9.5.0.71 or greater.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loSftp
LOCAL lcPath

lnSuccess = 0

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loSftp = CreateObject('Chilkat.SFtp')

* Pass a domain or IP address..
lnSuccess = loSftp.Connect("my-sftp-server.com",22)
IF (lnSuccess = 1) THEN
    lnSuccess = loSftp.AuthenticatePw("mySFtpLogin","mySFtpPassword")
ENDIF

IF (lnSuccess = 1) THEN
    lnSuccess = loSftp.InitializeSftp()
ENDIF

IF (lnSuccess <> 1) THEN
    ? loSftp.LastErrorText
    RELEASE loSftp
    CANCEL
ENDIF

* In this example, the we already have a symbolic link named "sshd_config"
* in our SSH/SFTP user account's HOME directory.  Get the target of this link:
lcPath = loSftp.ReadLink("sshd_config")
IF (loSftp.LastMethodSuccess <> 1) THEN
    ? loSftp.LastErrorText
    RELEASE loSftp
    CANCEL
ENDIF

? "symlink target path = " + lcPath

* Output is:  
* symlink target path = /etc/ssh/sshd_confi

RELEASE loSftp