SharpSSH gets stuck in an infinite stream read in C# SSH app
- by Ric Coles
Afternoon all,
I'm having a small problem with the SharpSSH library for .Net
(see http://www.tamirgal.com/blog/page/SharpSSH.aspx)
SshStream ssh = new SshStream("some ip address", "some username", "some password");
ssh.Prompt = "\n";
ssh.RemoveTerminalEmulationCharacters = true;
ssh.Write("ssh some ip address");
// Don't care about this response
ssh.ReadResponse();
ssh.Write("lss /mnt/sata[1-4]");
// Don't care about this response (for now)
ssh.ReadResponse();
// while the stream can be read
while (ssh.CanRead)
{
Console.WriteLine(ssh.ReadResponse());
}
ssh.Close();
As you can see, it's fairly straight forward.
However, when the while-loop gets stepped into, it won't break out of the loop when everything has been printed to the console and there is nothing else to read.
Is there anyway I can manually force it to break when there is nothing else to be read?
Cheers,
Ric