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

Newbie Script ???

Status
Not open for further replies.

phonejack99

Technical User
Jul 21, 2003
156
US
I'm just starting to use scripts on a regular basis and have noticed an issue on some of my Nortel PBX's. Below is a snip of a script that I've been using. My issue is that sometimes the PBX will respond with the "MARP" prompt and sometimes it will not. When it does the script below works like a charm of course when it does not the script bombs.

My question is -- is there a way to have a conditional wait for or an if this (MARP prompt) then that type of command that I can incorporate into the script?

Thanks in advance for your help!!!

waitfor "REQ:"
transmit "CHG^M"

waitfor "TYPE: "
transmit "3903 ^M"

waitfor "TN "
transmit "34 7^M"

waitfor "ECHG "
transmit "YES^M"

waitfor "ITEM "
transmit "KEY 2 MCR 8470 D^M"

waitfor "MARP"
transmit "^M"

waitfor "CPND "
transmit "^M"

waitfor "VMB "
transmit "^M"

waitfor "KEY "
transmit "3 MCR 8470 D^M"

waitfor "MARP"
transmit "^M"

waitfor "CPND "
transmit "^M"

waitfor "VMB "
transmit "^M"

waitfor "KEY "
transmit "^M"

waitfor "ITEM "
transmit "^M"

waitfor "REQ:"
transmit "****^M"

 
There are a few different ways to work this, depending on the exact steps you are seeing (or sometimes seeing). You can use if waitfor "string" to execute code that only occurs if "string" appears. However, the downside to this is that your else statement may be firing (due to waitfor timing out after 30 seconds by default) when you don't want it to yet.

Another option is to use when target to call a procedure when a particular string is called, then return to the main procedure when it is done executing. I think it would work best in your case since you can set the when command at the beginning of the script and the called procedure can send the Enter key in the cases above. Then, the script should drop down to the next waitfor and proceed.


 
the problem is if that number is already marped on another set, the switch stops because you need an extra ^M. if you transmit the ^M and that is a new dn, it auto marps, and the ^M reutrns the next line. if you find a work around, let me know. might get a better answer in the nortel forum

john poole
bellsouth business
columbia,sc
 
You can do something like this:

string compare1
string txtstr = "MARP"
...

waitfor " " ; put here the amount of spaces from the left side of the window till the M or C from MARP or CPND.
rget compare1 4 ; this will put the next 4 caracters into 'compare1'
if strcmp compare1 txtstr
transmit "^M"
waitfor "CPND "
endif
transmit "^M"
waitfor "VMB "
transmit "^M"
...

In this part the script will compare the txtstr with the 4 caracters capture bij the rget command. If these 2 match it will send a ^M and waitfor the CPND prompt. If the strings don't match you know for sure there is no MARP prompt.

Goodluck!
Jacco.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top