(Swift) SFTP SymLink - Create Symbolic Link on Server
Demonstrates how to create a symbolic link on the SFTP server.
func chilkatTest() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let sftp = CkoSFtp()!
// Pass a domain or IP address..
var success: Bool = sftp.connect("my-sftp-server.com", port: 22)
if success == true {
success = sftp.authenticatePw("mySFtpLogin", password: "mySFtpPassword")
}
if success == true {
success = sftp.initializeSftp()
}
if success != true {
print("\(sftp.lastErrorText!)")
return
}
// 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", newPath: "sshd_config")
if success != true {
print("\(sftp.lastErrorText!)")
return
}
print("Successfully created symbolic link.")
}
|