This project is read-only.

Receiving no result, no response from remote linux server

Dec 11, 2013 at 10:32 AM
Hi all,
I'm trying to execute few commands on remote linux server through SSH.NET (SshClient). I'm getting connected successfully, but when I gave new command suppose (cd mydir) I don't receive any error message, exception or any result, even no info from SshCommand.OutputStream.
Please help me... how I can get my work done..

private void txtQuery_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            txtResult.Clear();

            var cmd = client.CreateCommand(txtQuery.Text.Trim());
            var asynch = cmd.BeginExecute();
            var reader = new StreamReader(cmd.OutputStream);
            while (!asynch.IsCompleted)
            {
                var result = reader.ReadToEnd();
                if (String.IsNullOrEmpty(result))
                    continue;
                else
                {
                    txtResult.AppendText(result + "\r\n");
                }
            }
            string cmdResult = cmd.EndExecute(asynch);
            if (!String.IsNullOrEmpty(cmdResult))
            {
                txtResult.AppendText("\r\n\r\n\r\n" + cmdResult);
            }



        }
    }

Suppose I'm connecting by given host, name and password, the next thing what i'm doing as testing .......... I have a TextBox named "txtQuery" .... I write a command in the text box and wanted to see results (error, exceptions or whats so ever is that) to a new TextBox named "txtResult"........ I give many commands but received no ERROR, EXCEPTION or other info.