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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Questions concerning WAITFOR

Status
Not open for further replies.

worknman

Technical User
Feb 24, 2004
3
US
I'm wondering if it's possible to do the following with ASPECT:

I want to be able to transmit "something^M" to a remote host and wait for a response.
When the response comes, if WAITFOR is 'foo', I want to call function foo. If WAITFOR is 'bar', I want to call function bar. If WAITFOR is anyting else, then display a msgbox and terminate the script. Something like this:

transmit "something^M"
if waitfor "foo" 5
;Call function foo
elseif waitfor "bar" 5
;Call function bar
else
usermsg "Unexpected value!"
exit
endif

I tried the above, and it doesn't seem to work. Though I can get the 'if waitfor' part to work, that can only tests for one possibility of waitfor - like "either waitfor is 'foo' or anything else', not "if wait for is 'foo', 'bar', or anything else".
Is it possible to test for mulitple WAITFOR responsees, or better yet, assign WAITFOR to a string and/or use it a switch statement?

One other thing about WAITFOR .. is it possible when I transmit "something^M" to make my script look for the very first response back from the remote host instead of having to wait for N seconds?

TIA :)
 
Another user sent me a procedure a couple years ago that looks for three strings, then returns a value indicating which of the three strings was returned first (or if none of the strings specified were found in the time limit). You can find it here:


You can use the rget command to get back the text received immediately after sending a command. You may need to run the command twice to get the first actual data sent back from the remote system as the first rget command may get the echo of your command as sent by the other machine.


aspect@aspectscripting.com
 
I haven't tried this but I think you can use:

when target 0 "foo" Call foo
when target 1 "bar" Call bar

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top