午後はみんな、
.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 ループがステップインすると、すべてがコンソールに出力され、他に読み取るものが何もない場合、ループから抜け出すことはありません。
他に読むものがないときに手動で強制的に壊すことができる方法はありますか?
乾杯、リック