整个下午,
我对 .Net 的 SharpSSH 库有一个小问题(请参阅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();
如您所见,它相当简单。
但是,当进入while循环时,当所有内容都打印到控制台并且没有其他内容可读取时,它不会跳出循环。
无论如何,我可以在没有其他内容可读取的情况下手动强制它中断吗?
干杯,里克