Hi,
I am using SSH.Net library to connect linux server and executing some cmds. I am trying to read the out put of the command like below.. but it is returning only first row of the result. If I ran the same cmd in linux directly i will get multiple rows result. Please help to fix my code.
```
var cmd = ssh.CreateCommand("mycmd"); //It is a linux shell script it ran and gives output
var asynch = cmd.BeginExecute(delegate(IAsyncResult ar)
{
Response.Write("Finished.");
}, null);
var reader = new StreamReader(cmd.OutputStream);
while (!asynch.IsCompleted)
{
var result = reader.ReadLine();
Response.Write(result);
if (string.IsNullOrEmpty(result))
continue;
}
cmd.EndExecute(asynch);
```
Comments: ** Comment from web user: da_rinkes **
I am using SSH.Net library to connect linux server and executing some cmds. I am trying to read the out put of the command like below.. but it is returning only first row of the result. If I ran the same cmd in linux directly i will get multiple rows result. Please help to fix my code.
```
var cmd = ssh.CreateCommand("mycmd"); //It is a linux shell script it ran and gives output
var asynch = cmd.BeginExecute(delegate(IAsyncResult ar)
{
Response.Write("Finished.");
}, null);
var reader = new StreamReader(cmd.OutputStream);
while (!asynch.IsCompleted)
{
var result = reader.ReadLine();
Response.Write(result);
if (string.IsNullOrEmpty(result))
continue;
}
cmd.EndExecute(asynch);
```
Comments: ** Comment from web user: da_rinkes **
Maybe the Output is hiding in Stderr/ExtendedOutputStream?
You can check it with redirecting Stderr to /dev/null:
$ your_command 2> /dev/null