title: Running a command that produces no output with SharpSSH
body: <p>I want to run a command using ssh.<br>
  I am using the <a href="https://sourceforge.net/projects/sharpssh/" rel="nofollow noreferrer">SharpSSH library</a>, as in this example:</p>
  
  <pre><code>using System;
  using Tamir.SharpSsh;
  
  class Program {
      static void Main(string[] args) {
          string hostName = "host.foo.com";
          string userName = "user";
          string privateKeyFile = @"C:\privatekey.private";
          string privateKeyPassword = "xxx";
  
          SshExec sshExec = new SshExec(hostName, userName);
          sshExec.AddIdentityFile(privateKeyFile, privateKeyPassword);
          sshExec.Connect();
          string command = string.Join(" ", args);
          Console.WriteLine("command = {0}", command);
          string output = sshExec.RunCommand(command);
  
          int code = sshExec.ChannelExec.getExitStatus();
          sshExec.Close();
          Console.WriteLine("code = {0}", code);
          Console.WriteLine("output = {0}", output);
      }
  }
  </code></pre>
  
  <p>My problem is that when the command I run produces no output, I get -1 as return code, instead of the code returned by the command on the remote machine.<br>
  Has someone encountered this problem, or am I doing something wrong? </p>