SSH.NET How to return a boolean from command execution

1.5k views Asked by At

I am new to the SSH.NET library and I understand the basics of it such as connecting, executing a command and returning the output.

But my question is, how can I return a true/false statement if I wanted to check if a background process is running or not?

So for example:

  using (SshClient client = new SshClient(host, user, pass))
  {
      client.Connect();
      var cmd = client.RunCommand("uname -sn");
      string serverResponse = cmd.Result;
      Label1.Text = serverResponse;
      client.Disconnect();
  }

So if I wanted to replace my command with "ps -u user | grep procName" I would like to have it tell me yes or no if said procName is running.

How would I go about this?

0

There are 0 answers