diff options
author | Julien Dessaux | 2022-03-18 10:48:37 +0100 |
---|---|---|
committer | Julien Dessaux | 2022-05-22 01:24:56 +0200 |
commit | 841c2f47edfb2967f8ad18e6c9568c8dd8be6298 (patch) | |
tree | 359a5a7b2e4eb72cb65f3cf9f30cfd39ba1dc917 /src/main.zig | |
parent | initial import (diff) | |
download | zigod-841c2f47edfb2967f8ad18e6c9568c8dd8be6298.tar.gz zigod-841c2f47edfb2967f8ad18e6c9568c8dd8be6298.tar.bz2 zigod-841c2f47edfb2967f8ad18e6c9568c8dd8be6298.zip |
Added basic ssh client to run commands
Diffstat (limited to '')
-rw-r--r-- | src/main.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..3b16914 --- /dev/null +++ b/src/main.zig @@ -0,0 +1,22 @@ +const std = @import("std"); + +const ssh = @import("ssh.zig"); + +pub fn main() anyerror!void { + var client = ssh.Client.init("localhost") catch unreachable; + const stdout = std.io.getStdOut(); + client.run("pwd", stdout) catch unreachable; + client.run("who", stdout) catch unreachable; + client.deinit(); +} + +test "basic test" { + // this test requires you can ssh localhost without a password prompt + // (typically by having your ssh_agent running) + var client = ssh.Client.init("localhost") catch unreachable; + var buffer = std.ArrayList(u8).init(std.testing.allocator); + defer buffer.deinit(); + client.run("echo test", buffer.writer()) catch unreachable; + try std.testing.expectEqualSlices(u8, buffer.items, "test\n"); + client.deinit(); +} |