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

New Post: VB.net SSH client with VB.net

$
0
0
Hi -
( my VB is mot the best ... so if response is in C# ..then i'm goosed !)
I want to write a vb app that will :
  1. Connect to a device through SSH.
  2. Send a list commands and wait for the response of each command, before sending the next.
    I'd like each response to go to a textbox.
I've seen sharpssh which I can get to work - kind of - but I have to put in the expected prompt for each command ... I don't want to do that .. I just want to see the full response in the textbox ... before I send the next command.

I've also seen renci .. but for some reason cant get that to work

For sharpssh - I don't want to have to enter something for sshstr.prompt .. I just ant to see the full responce..

any ideas how I could do this ?
thanks



Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim result As String
    Dim sshstr As New SshStream("10.226.145.108", "super", "super")
    TextBox1.Text = "Connecting ...."
    Me.Refresh()

    sshstr.Prompt = "TSM"

    '//Remove terminal emulation characters
    sshstr.RemoveTerminalEmulationCharacters = True

    TextBox1.Text = sshstr.ReadResponse()
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    MsgBox(" 1")
    System.Threading.Thread.Sleep(5000)
    Threading.Thread.Sleep(1000)
' command # 1
    sshstr.Write("/c 1")
    TextBox1.AppendText("/c 1")
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    Me.Refresh()
    System.Threading.Thread.Sleep(2000)
     sshstr.Prompt = ""
    result = sshstr.ReadResponse()

    TextBox1.AppendText(result)
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    Threading.Thread.Sleep(1000)
' command # 2
    sshstr.Write(Chr(24))
    sshstr.Write(Chr(13))
    TextBox1.AppendText("Chr(24)")
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    Me.Refresh()
    sshstr.Prompt = "TSM"
    result = sshstr.ReadResponse()
    TextBox1.AppendText(result)
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    sshstr.Close()

    ' //Reading from the SSH channel

End Sub


Viewing all articles
Browse latest Browse all 1729

Trending Articles