I am currently trying to "talk" to a router using SSH commands via C#.
I am using the SSH.net model.
public void connectSSH(string hostName, string username, string password)
{
using (var client = new SshClient(hostName, username, password))
{
client.Connect();
client.RunCommand(CommandList.showEnvironment());
client.Disconnect();
}
}
This is the code I have so far (all the commands are in another file). Ideally I would be able to capture the response of the router to the command, rather than just delivering and executing commands one-way.
How can I capture the response? For example; the command "show environment" responds with a list of factors
Unit Temperature Descr/ID Current/Threshold Range
1 Central Temperature/1 27C/11~79C Status code: * temperature is out of threshold range Detail Fan
A SshCommand in SSH.net contains the properties Result and Error for responses. I guess your CommandList is just a List ? After running your command you should be able to retrieve your result from the 2 properties.