2013. 12. 7. 05:20
SSH.NET Useful Examples
2013. 12. 7. 05:20 in 3. Implementation/WPF & Silverlight

For a few days I was digging how to show the log in real time when running a linux command with SSH.NET. It doesn't look easy but thankfully there is simple way to do that. Here is an example:
client.Connect(); var cmd = client.CreateCommand("ls -l"); // very long list cmd.CommandTimeout = TimeSpan.FromSeconds(30); var asynch = cmd.BeginExecute(); var reader = new StreamReader(cmd.OutputStream); while (!asynch.IsCompleted) { var result = reader.ReadToEnd(); if (string.IsNullOrEmpty(result)) continue; Console.Write(result); } cmd.EndExecute(asynch); client.Disconnect();
Source: https://sshnet.codeplex.com/documentation