Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Waitfor - more than 1 target string?

Status
Not open for further replies.

PhilBreau

Technical User
Dec 14, 2001
108
CA
Is there a way of waitfor condition where there can be more than 1 target string. This would be like having 2 waitfor statements running simultaneously



example

proc main

string a

waitfor string ;I know waitfor is conditional and
;suspend until target is met up to timeout


if a == "end of report"
transmit "^C"
endif

if a == "press enter to continue"
transmit "^M"
endif

etc


I don't know how comread can help. The response from the host can vary when downloading reports. Screen prints require the use of enter between screens. for each screen I take a snapshot. The last screen will display a message to press break. Reports can have varying number of pages. Because of the emulation, capture doesn't provide desired results regardless of capture options (filtered,raw,as it appears on screen, etc)

 
Waitfor can only have one string as its target. In your case, you might be better off using two when commands. At the beginning of your script, you would need these two lines:

when target "end of report" call endreport
when target "press enter to continue" call continue

You would then have two procedures called endreport and continue that looked as such:

proc endreport
transmit "^C"
endproc

proc continue
transmit "^M"
endproc

Anytime that Procomm received the "end of report" string, the endreport procedure would be called, the ^C would be transmitted, and then control would be returned to the previous part of the script. The same applies for the "press enter to continue" situation.

 
I am brand new to Aspect - one week of experience - so my questions are kind of basic.

1.) I have a situation where I am capturing logs. After I capture them I want to move on and transmit the next command.

I might get zero logs or two logs or thirty logs.

In the first case I can use a waitfor "zero (0) logs"

I think I figured out how to use an IF statement but the problem is how can I use a waitfor for an unkown quantity of logs - each will give the same string i.e. "END OF REPORT" that indicates the end of each individual log but it is here that I get stuck - how can I capture an unspecified amount of logs then transmit the next command ?

2.) Also is there way to pause the script a few seconds ?
EXAMPLE transmit "command_X ^M"
waitfor "string"
pause 10 seconds
tramsmit "command_Y ^M"

This would help the script from stopping - sometimes after executing a command and getting the output the system is not ready to process the next command for a few seconds. The result is a "system busy - try again later" and the script stops but a pause would solve this problem.

thx

 
I'll tackle these in reverse order since the last one is a bit easier. You can use "pause 10" to have the script wait 10 seconds before continuing.

As for the first problem, there are a couple different ways to handle this, but I would need to see just what the system is sending to you to see what would work best. Also, when that message comes across, is the cursor on the same line as the message with the number of logs? Also, are you capturing each log to the same file, or does each log go in its own file?


 
The system is sending END OF REPORT followed by the date after each log.

The system does indicate the number of logs unless there are no logs in which case it sends a message something to the effect ZERO (0) REPORTS

The cursor is not on the same line it drops down below the output.

something like this for say two logs:
-----------------------------
Log info
More log info
Even more log info
yet even more log info
END OF REPORT 05 02 05
-------------------------
Log info
More log info
Even more log info
yet even more log info
END OF REPORT 05 02 05
--------------------------
(blinking cursor)

All the logs, as well as everything else, are going to the same capture file.

 
So the only time you are informed of the number of logs that will be sent is when there are none? And I take it that no prompt or other indication can tell you when the last log is received? If so, then the only option you have is to check for the receive line being quiet for a specified number of seconds. This will work well if all of the logs come one after another with no delay. This command:

waitquiet 15 FOREVER

will tell your script to wait until no data has been received for 15 seconds (modify that value to suit the machine you are receiving data from). You would want to issue that command just after you send the command (I presume) to receive the logs.


 
Thanks much

Yep - you got the details right.

That should work - all the logs do come one after the other with no delay between

here is what I plan to use:

transmit “^A get_log ^M”
waitfor “ZERO (0) REPORTS”
if timeout then
waitquite 5 FOREVER
transmit "^A get_card_stat ^M”
else
transmit "^A get_card_stat ^M”

Again thx for the help - this has turned out to be a great site.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top