Re: Missing wait for response in SSH.net buffer an - WeOnlyDo Discussion board

Re: Missing wait for response in SSH.net buffer an (General questions)

by Simon, Friday, April 24, 2009, 10:40 (5691 days ago) @ woddrazen

Ok, I have managed to get this to work with this code below. A suggestion to the developers, that if you are setting the wait for as in a = ssh1.WaitFor( regex:[$ #>]$ , 10) then set the variable a to include the waitfor character as this is actually received in the buffer, This then will save us having to put the catch
If ssh1.DataReady > 0 Then
a = ssh1.Receive
ssh1.DataReady = 0
End If


What are peoples thoughts on this? I am now progressing. Thanks for the help.

MODIFIED CODE:

Try
ssh1.Connect()
a = ssh1.WaitFor( Password: , 10)
TextBox1.Text = TextBox1.Text & a
ssh1.Send( cisco + vbLf)
a = ssh1.WaitFor( regex:[$ #>]$ , 10)
TextBox1.Text = TextBox1.Text & a
If ssh1.DataReady > 0 Then
a = ssh1.Receive
TextBox1.Text = TextBox1.Text & a
ssh1.DataReady = 0
End If
ssh1.Send( sho env + vbLf)
a = ssh1.WaitFor( regex:[$ #>]$ , 10)
TextBox1.Text = TextBox1.Text & a
If ssh1.DataReady > 0 Then
a = ssh1.Receive
TextBox1.Text = TextBox1.Text & a
ssh1.DataReady = 0
End If
ssh1.Send( sho int desc + vbLf)
a = ssh1.WaitFor( regex:[$ #>]$ , 10)
TextBox1.Text = TextBox1.Text & a
If ssh1.DataReady > 0 Then
a = ssh1.Receive
TextBox1.Text = TextBox1.Text & a
ssh1.DataReady = 0
End If
MsgBox( done )
Catch ex As Exception
MsgBox( Exception & ex.Message)
End Try


Complete thread: