Hi There
I am trying to use SSH.Net in a WinForms app, however I am having issues trying to ouput the result of a command to a listbox. I can connect fine to the server.
Debugging the line with string output I get "output = "Renci.SshNet.SshCommand" The value of command is correct with ls -la
I am trying to use SSH.Net in a WinForms app, however I am having issues trying to ouput the result of a command to a listbox. I can connect fine to the server.
Debugging the line with string output I get "output = "Renci.SshNet.SshCommand" The value of command is correct with ls -la
private void btnExecute_Click(object sender, EventArgs e)
{
var connectionInfo = new PasswordConnectionInfo(host, port, username, password);
lblStatus.Text = "Trying SSH connection...";
//connectionInfo.Timeout = TimeSpan.FromSeconds(10);
using (var client = new SshClient(connectionInfo))
{
client.Connect();
if (client.IsConnected)
{
lblStatus.Text = "SSH connection is active";
string command = ("ls -la");
string output = client.RunCommand(command).ToString();
listBox1.Text = output;
}
else
{
lblStatus.Text = "SSH connection has failed";
}
//client.Disconnect();
}
}
Some help would be appreciated :-)