Zig
Zig
SFTP SymLink - Create Symbolic Link on Server
See more SFTP Examples
Demonstrates how to create a symbolic link on the SFTP server.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
var success: bool = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const sftp = try chilkat.SFtp.init();
defer sftp.deinit();
// Pass a domain or IP address..
success = if (sftp.connect("my-sftp-server.com", 22)) true else |_| false;
if (success) {
success = if (sftp.authenticatePw("mySFtpLogin", "mySFtpPassword")) true else |_| false;
}
if (success) {
success = if (sftp.initializeSftp()) true else |_| false;
}
if (!success) {
std.debug.print("{s}\n", .{try sftp.getLastErrorText(alloc)});
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.
sftp.symLink("/etc/ssh/sshd_config", "sshd_config") catch {
std.debug.print("{s}\n", .{try sftp.getLastErrorText(alloc)});
return;
};
std.debug.print("Successfully created symbolic link.\n", .{});
}