Getting blank output using template example

Jun 9, 2014 at 4:18 PM
I'm trying to create a very simple script that runs basic commands in a .cshtml page. I can get feedback for standard commands like "ls -l" or "ps -A", but when I try to run a command like "top" or another custom command, I don't get any feedback. It seems like maybe the output type is different for a command that launches a script? The example below is attempting to execute a command that runs a custom script to check if a specific application is running. In my Putty session, I get a response message like "(PID: 19931) is running," but when I run the same command in the code below, I get a blank response (except it does write "Finished" as shown in the code). So I'm not getting any exception errors, just no feedback. I've searched on the forum quite a lot and tried to figure it out myself with no success. Any help is greatly appreciated.
var connectionInfo = new PasswordConnectionInfo(RemoteHost, RemoteUserName, RemotePassWord); 
using (var ssh = new SshClient(connectionInfo))
var cmd = ssh.CreateCommand("service tpw status");   //  very long list
                var asynch = cmd.BeginExecute(delegate(IAsyncResult ar)
                }, null);

                var reader = new StreamReader(cmd.OutputStream);

                while (!asynch.IsCompleted)
                    var result = reader.ReadToEnd();
                    if (string.IsNullOrEmpty(result)){

Jun 9, 2014 at 4:49 PM
I got it to run by using the code below. Am I doing this the best way, or is something else recommended?
var connectionInfo = new PasswordConnectionInfo(RemoteHost, RemoteUserName, RemotePassWord); 
var ssh = new SshClient(connectionInfo);
var shellStream = ssh.CreateShellStream("xterm", 80,24, 800, 600, 1024);
shellStream.WriteLine("service tpw status");
var output = shellStream.Expect("running");
if (output.Contains("running")){
Response.Write("TPW on " + RemoteHost + " is running");
Jun 17, 2014 at 10:22 PM

This method works great for me, except when I have a lot of output coming back from the command. Then the buffer returns a truncated version of the output...

I'm still working on the 'async' methods to find a way to save unlimited output...