SharpSSH gets stuck in an infinite stream read in C# SSH app
Posted
by Ric Coles
on Stack Overflow
See other posts from Stack Overflow
or by Ric Coles
Published on 2010-03-12T15:49:55Z
Indexed on
2010/05/11
13:54 UTC
Read the original article
Hit count: 378
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
© Stack Overflow or respective owner