ssh.net no output

Apr 8, 2012 at 12:07 AM

im using SSH.NET as one of my libraries to access a machine via SSH protocol, so here, I tried creating some code, but ended up no output

using (var client = new SshClient("10.8.2.3", "root", "password"))
               
{
                    client
.Connect();
                   
var cmd = client.RunCommand("cd /etc/openvpn");
                    cmd
.Execute();
                   
var cmd1 = client.RunCommand("vi log.log");
                    cmd1
.Execute();
                   
var cmd2 = client.RunCommand("/In case of rekeying this note is ok");
                    cmd2
.Execute();
                   
string message = cmd2.Error;

                    client
.Disconnect();
               
}

basically, what Im trying to achieve is login, change directory, use vi to search contents of a file and get the error message. I debug and build it but it doesnt continue (no output), maybe it hangs somewhere. What could have gone wrong in the code? Thanks

Coordinator
Apr 9, 2012 at 5:50 PM

You should check for command properties since this is where you should see the result of command execution.

Also, you cannot use cd in command context, well, you can, but it will not have any effect on the next command.

 

Thanks,

Oleg

Apr 10, 2012 at 4:11 AM
Tnx

Sent from my iPhone
Apr 20, 2012 at 2:24 AM

try as fllow

var cmd1 = client.RunCommand("cd /etc/openvpn; vi log.log");