Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Commented Unassigned: How to read linux cmd output all lines [1963]

$
0
0
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 **

Maybe the Output is hiding in Stderr/ExtendedOutputStream?
You can check it with redirecting Stderr to /dev/null:

$ your_command 2> /dev/null


Viewing all articles
Browse latest Browse all 1026

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>