Difference between WaitFor, ReadUntil and CheckFor

0 votes
asked Jun 9, 2015 by mschaeffer (170 points)


what exactly is the difference between WaitFor, ReadUntil and CheckFor? Which method is best suited for what purpose?
Background of the question is, I´m using Compact Framework and I can`t detect the prompt. Therefore finding your way in a virtual terminal is a bit complicated ...

1 Answer

0 votes
answered Jun 9, 2015 by Pavel Matyska (15,060 points)


Scripting.WaitFor and Scripting.ReadUntil methods are both for the same purpose, they both receive data from the server, but they differ in their return values. Scripting.WaitFor is intended for uses where you want to check what was the reason of returning from the method, e.q. if the prompt was matched (if it was in ScriptEvent input parametes), or if the match was success in general and so on.
Scripting.ReadUntil returns the data it receives.
You can get both ScriptMatch and received data from Scripting.LastResult and Scripting.ReceivedData, if you need all information you can get. It doesn't matter which method you call, they are for your convenience.
On the other hand, Scripting.CheckFor does not receive any data and check the state in which the terminal is currently in. So you can read until some string and then check if it appears on the right position. Or wait until prompt is received and then check if the line above the current line have the prompt as well.

Scripting.DetectPrompt() is not working for you?

commented Jun 9, 2015 by mschaeffer (170 points)
No, it doesn`t work for me. Always I try I get the error: "Response reading timed out".
commented Jun 9, 2015 by Pavel Matyska (15,060 points)
Is it possible for you to create a  communication log (with LogLevel.Verbose) following this kb article:

and send it to support@rebex.net for analysis? Thanks.
commented Jun 10, 2015 by mschaeffer (170 points)
Hi Pavel,

in the log file with LogLevel Verbose are sensitive contents.
Do they need all "Received Data" in the log to investigate it properly?
commented Jun 10, 2015 by Pavel Matyska (15,060 points)
Hi, we do not need any sensitive content. You can overwrite the passwords or delete the beginning of the file. Just make sure to leave welcome message or any other data that follows login procedure. The log should contain "DetectPrompt" log message, so this is most likely the start of the part we need. If you can leave one command (send and receive in the log) before this "DetectPrompt" message, it can help too.
commented Jun 10, 2015 by mschaeffer (170 points)
The only log with DetectPrompt is:
06-10 01:56:06 DEBUG VirtualTerminal(0)[389761774] Scripting: DetectPrompt()

After that it starts with:
2015-06-10 01:56:06 DEBUG VirtualTerminal(0)[389761774] Scripting: WaitFor(delay: 400)

then there is a lot of "Received Data" until it ends with:
2015-06-10 01:56:28 DEBUG VirtualTerminal(0)[389761774] Scripting: WaitFor(delay: 3224)
commented Jun 10, 2015 by Pavel Matyska (15,060 points)
Yes, that is the correct part. Is the timeout exception thrown after that "Scripting: WaitFor(delay: 3224) log" message? What data are received between the first "Scripting: WaitFor(delay: 400)" and the last "Scripting: WaitFor(delay: 3224)" log messages? Those Received Data messages should contain something that is actually the prompt.
There also should be messages like this:

Info: Sent data:
 0000 |0D                                             | .

 If those data do not contain any sensitive information, is is possible to send it to support@rebex.net?

Just for clarification, those "Scripting: WaitFor(delay: <number>)" messages come from the Scripting.DetectPrompt() call as it uses Scripting.WaitFor(delay) internally.
commented Jun 10, 2015 by mschaeffer (170 points)
Thank you for the time being, email is on its way...
commented Jun 10, 2015 by Pavel Matyska (15,060 points)
Yes, we have receive it just now, so I'll be going through it and get back to you by an email. Thank you for the log.
commented Jun 10, 2015 by Pavel Matyska (15,060 points)
The log we received does not contain anything that appears as a prompt.