PHP
Chilkat2 PHP
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 PHP Downloads
<?php
use Chilkat2\SFtp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$sftp = new SFtp();
// Pass a domain or IP address..
try {
$sftp->Connect('my-sftp-server.com', 22);
$sftp->AuthenticatePw('mySFtpLogin', 'mySFtpPassword');
$sftp->InitializeSftp();
// 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:
$path = $sftp->ReadLink('sshd_config');
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo 'symlink target path = ', $path, "\n";
// Output is:
// symlink target path = /etc/ssh/sshd_config