0

I am trying to use SharpSSH to use the "view" command in the shell to read a file remotely. I am able to access and view it, but it only returns about 120 lines or so before the form locks up with no exception being thrown. Here is my code:

    SshStream Shell = null;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        string host = "10.100.100.15";
        string user = "root";
        string password = "pass";

        Shell = new SshStream(host, user, password);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (Shell != null)
        {
            try
            {

                Shell.Write("cd /var/log");
                Shell.Write("view info.log");

                StreamReader reader = new StreamReader(Shell);
                string inputLine = Shell.ReadResponse();

                while ((inputLine = reader.ReadLine()) != null)
                {
                    lstLines.Items.Add(inputLine);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

I am still learning to use this code, so I am just trying to display the lines that it returns in a listbox. There are about 2200 lines in the file, but it only returns about 100.

1 Answers1

1

I've found a solution for my problem. Instead of using "view info.log", and am using "cat info.log". It shows all lines without prompting to continue. Thanks for your help!