SSH view command output in real time

Nucleus

Active member
Joined
May 24, 2005
Messages
30
Programming Experience
Beginner
Hi,
I am trying to create an application that runs bash scripts on a remote Linux computer. The scripts already exist on the Linux computer, I just want to run them using this application. I'm using SSH NET by Renci to establish the SSH connection.

The scripts are expected to provide full output of what's happening, and they do, but only after the whole script is finished, which could take up to 30 seconds. After the script is finished I get a full output of what happened when the script was running.

I would like to see the output of the script while its running. Not after its finished.
How can I do that?

VB.NET:
Public Class SSH
    Dim connInfo As New Renci.SshNet.PasswordConnectionInfo("host", "port", "user", "pass")
    Dim cmd As Renci.SshNet.SshCommand
    Protected Sub btn1_Click(sender As Object, e As EventArgs) Handles btn1.Click
        Dim sshClient As New Renci.SshNet.SshClient(connInfo)
        Using sshClient
            sshClient.Connect()
            cmd = sshClient.RunCommand("/home/user/script1")
            rtbresult.Text = cmd.Result
            sshClient.Disconnect()
        End Using
    End Sub
    Protected Sub btn2_Click(sender As Object, e As EventArgs) Handles btn2.Click
        Dim sshClient As New Renci.SshNet.SshClient(connInfo)
        Using sshClient
            sshClient.Connect()
            cmd = sshClient.RunCommand("/home/user/script2")
            rtbresult.Text = cmd.Result
            sshClient.Disconnect()
        End Using
    End Sub
End Class
 
Back
Top