Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Subscribe to DataReceived Event of ShellStream

$
0
0
Hello folks,
I would like to implement a service where I´m able to parse the results of the Linux command top.
So every second my server returns a new result of the performance stats.

I already tried the following:
public void CreateShellStream(int hashCode, string command, string idetifier)
        {
            var con = GetConnection(hashCode);
            IConnectionPart part = new ConnectionPart();
            part.Shell = con.Connection.CreateShellStream(idetifier, 0, 0, 0, 0, 1024);            
            part.Shell.WriteLine(command);
            part.Shell.WriteLine(Cryption.ToInsecureString(con.Password));
            part.Shell.DataReceived += Shell_DataReceived;
            con.Shells.Add(part);
        }

        void Shell_DataReceived(object sender, ShellDataEventArgs e)
        {
            var str = System.Text.Encoding.Default.GetString(e.Data);
            int i = 0;
        }
The problem is that I only receive in the subscribed event the command I passed to the Shell, but I get no result of the server.

Is there an other way to reach this?

greetings
WhiteIntel

Viewing all articles
Browse latest Browse all 1729

Trending Articles