Re: Trapping for error and displaying receive buff - WeOnlyDo Discussion board

Re: Trapping for error and displaying receive buff (General questions)

by Eric, Monday, December 10, 2007, 14:55 (6194 days ago) @ woddrazen

[size=2]Success[/size]

I wanted to update this post as I have found a solution using the prompte method.

[code]
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click

Telnet1 = New WODTELNETDLXCOMLIB.wodTelnetDLXComClass
Telnet1.Timeout = 4
Telnet1.Hostname = textBox2.Text
Telnet1.Login = textBox3.Text
Telnet1.Password = textBox4.Text
Telnet1.Protocol = WODTELNETDLXCOMLIB.ProtocolsEnum.Telnet
'Telnet1.Port = 22
Telnet1.Blocking = 1
Telnet1.StripANSI = True

Telnet1.Prompt = p5104 - Select:
ExecCount = 0

Telnet1.Connect()
End Sub

Private Sub AddToList(ByVal Text As String)
textBox1.AppendText(Text)
End Sub

Private Sub Telnet1_Connected(ByVal ErrorCode As Short, ByVal ErrorText As String) Handles Telnet1.Connected
If ErrorCode <> 0 Then
AddToList( CONNECT error: & ErrorText & vbCrLf)
Else
AddToList( CONNECTED! & vbCrLf)
End If
End Sub
Private Sub Telnet1_Disconnected() Handles Telnet1.Disconnected
AddToList( DISCONNECTED & vbCrLf)
End Sub

Private Sub Telnet1_PromptReceived() Handles Telnet1.PromptReceived
Select Case ExecCount
Case 0
AddToList(Telnet1.Prompt)
Telnet1.Prompt = p5104 - Select:
Telnet1.Send( T & vbCrLf)
Case 1
AddToList(Telnet1.Prompt)
Telnet1.Prompt = Dev
Telnet1.Send( e51 & vbCrLf)
Case 2
AddToList(Telnet1.Prompt)
Telnet1.Prompt = Exit
Telnet1.Send(vbCrLf)
Case 3
AddToList(Telnet1.Prompt)
Telnet1.Prompt = Password
Telnet1.Send( s51 & vbCrLf)
Case 4
AddToList(Telnet1.Prompt)
Telnet1.Prompt = Exit
Telnet1.Send( s51eagle & vbCrLf)
Case 5
AddToList(Telnet1.Prompt)
Telnet1.Prompt = Select
Telnet1.Send( 51 & vbCrLf)
Case 6
AddToList(Telnet1.Prompt)
Telnet1.Prompt = Select
Telnet1.Send( 3 & vbCrLf)
Case 7
AddToList(Telnet1.Prompt)
Telnet1.Prompt = Select
Telnet1.Send( 3 & vbCrLf)
Case 8
AddToList(Telnet1.Prompt)
Telnet1.Prompt = Employee
Telnet1.Send( bkn & vbCrLf)
Case 9
AddToList(Telnet1.Prompt)
Telnet1.Send( wrkrb & vbCrLf)
End Select

ExecCount = ExecCount + 1
End Sub

Private Sub Telnet1_Received(ByVal ByteCount As Short) Handles Telnet1.Received
Dim a As String

a = Telnet1.Receive(ByteCount, 0)
AddToList(a)
End Sub

[/code]

[size=2]Problems Found with Resolutions[/size]
Problem 1: ANSI Characters were causing the prompts to fail
Resolution 1:used strip ANSI to resolve issue
Problem 2: SSHAuto would not let script complete due to some characters not encoding properly
Resolution 2:Converted to Telnet Protocol
Problem 3: Sent data was not always working with menus
Resolution 3:Made sure all send data appended vbCrLf rather than vbLf


Complete thread: