RegEx matching on WaitFor or Prompt - WeOnlyDo Discussion board

RegEx matching on WaitFor or Prompt (General questions)

by rsg98, Wednesday, August 03, 2005, 19:38 (7051 days ago)

Been upsetting me all day this...
[code]
Try
SshConnection.Blocking = True
SshConnection.Send(strCmd & vbCrLf)
SshConnection.WaitFor( fullprompt-> )

strBuffer = SshConnection.Receive
strBufferToUse = strBuffer

Debug.WriteLine( ***BUFFER_STARTS** )
Debug.Write(strBuffer)
Debug.WriteLine( ***BUFFER_ENDS**** )

Catch ex As Exception
Return FirewallErrors.FWERROR_IOERROR
End Try
[/code]

How does the receive buffer work? The device I'm connecting to returns similar to this on connection:

Remote management interface
fullprompt->

Then I send it a command using the function above (which is separate to the actual connect function...

get blah

And using the above code, it works - but, the .Receive buffer contains the Remote management interface... etc. - so I think the Waitfor trips on the /first/ prompt, rather than waiting until the get blah command has completed then returning the data from that.

If I add in Debug.Print(SshConnection.Receive) before the .Send (to try and clear the buffer) then I don't get any of the expected results - the .Receive from the .Send command is empty.

Next (and the problem which pushed me away from .Execute towards trying with .Send) is using a regex instead of the fullprompt->. Using

regex:-> $

...which is a syntax which works for .NET native regex, makes the whole thing behave very strangely.

For now, I'd just be happy understanding how the .Receive buffer is supposed to work (is this a timing issue, waitfor running against existing buffer info before .send completes?)- or alternatively, figuring out a regex that will work with .Execute.

Huge... complicated... probably too rambling to solve!

Thanks,

Richard


Complete thread: