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

Writing a Procomm+ waitfor function with params

Status
Not open for further replies.

willy113

Programmer
Apr 27, 2004
33
US
ProcommPlus Rep,

I have used the ProcommPlus transmit and waitfor commands so much, that I would like to now write a function call with passed params to get rid of the thousands of hard coded lines of waitfor and transmit code.
I can get the waitfor to work with the 1st string param, but need a way to also concatinate the time integer, and 4 constants that can be concatinated to the end of this command.
I have attached some example code that I am working on.

If Procomm had a structure, then maybe this would work, since the waitfor command uses 3 parameters of different typedefs. (i.e. waitfor string, integer, constant, constant, constant, constant.

Any ideas and/or suggestions would be appreciated !!

;*****************************************************************************
;* PROCEDURE NAME: TransmitCall
;*----------------------------------------------------------------------------
;* CALLED BY: Any Procedure(s)
;* Description: : processes the ProcommPlus TRANSMIT command with ALL params per the spec
;* and then checks the FAILURE/SUCCESS flags and passes back a return msg
;* INPUT: transmitCmd, transmitXlate, transmitMsg
;* OUTPUT: FAILURE/SUCCESS
;* RETURN: TRUE/FALSE
;*****************************************************************************

func TransmitCall : integer
param string transmitCmd
param string transmitXlate
;param string transmitAddCR
;param string transmitAddLF
param string transmitMsg

string transmitString = ""

if nullstr transmitCmd
goto TC_CRASH
else
;strquote transmitCmd
strcat transmitString transmitCmd
;strcat transmitString " "
endif
if not nullstr transmitXlate
strcat transmitString " "
strcat transmitString transmitXlate
endif

strcat transmitString transmitCmd
strreplace transmitString "\0" ""
TRANSMIT transmitString
if FAILURE
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": FAILED`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
elseif SUCCESS
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": PASSED`r`n"
termmsg MyTermMsg
return TRUE
else
TC_CRASH:
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": ProcommPlus PASS/FAIL Transmit Program CRASHED !`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
endif
endfunc


;*****************************************************************************
;* PROCEDURE NAME: WaitForCall
;*----------------------------------------------------------------------------
;* CALLED BY: Any Procedure(s)
;* Description: : processes the ProcommPlus WAITFOR command with ALL params per the spec
;* and then checks the FAILURE/SUCCESS flags and passes back a return msg
;* INPUT: waitForCmd, waitForTime, waitForCase, waitForCase, waitForXlate, waitForStrip
;* waitForMsg
;* OUTPUT: FAILURE/SUCCESS
;* RETURN: TRUE/FALSE
;*****************************************************************************

func WaitForCall : integer
param string waitForCmd
param string waitForTime
param string waitForever
param string waitForCase
param string waitForXlate
param string waitForStrip
param string waitForMsg

string waitForString = ""
string waitForString2 = ""
string waitForString3 = ""
integer waitForTimeInt = 0
;string waitForString = "("

if nullstr waitForCmd
goto WFC_CRASH
else
;strquote waitForCmd
strcpy waitForString waitForCmd
endif
atoi waitForTime waitForTimeInt
;itoa waitForTime waitForTimeStr
if not nullstr waitForTime
strfmt waitForString "%s %i" waitForString waitForTimeInt
;strcat waitForString " "
;strcat waitForString waitForTime
endif
if not nullstr waitForever
strcat waitForString " FOREVER"
endif
if not nullstr waitForCase
strcat waitForString " MATCHCASE"
endif
if not nullstr waitForXlate
strcat waitForString " RAW"
endif
if not nullstr waitForStrip
strcat waitForString " STRIP"
endif

strreplace waitForString "\0" ""
strreplace waitForString "`"" ""
strfmt myErrorMsg "`r`nMY WAITFOR Messsage is: %s`r`n" waitForString
termmsg myErrorMsg

WAITFOR waitForString
;WAITFOR (waitForCmd, waitForTime, waitForever, waitForCase, waitForXlate, waitForStrip) NO TEST MESSAGE INCLUDED
if FAILURE
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": FAILED`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
elseif SUCCESS
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": PASSED`r`n"
termmsg MyTermMsg
return TRUE
else
WFC_CRASH:
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": ProcommPlus PASS/FAIL Waitfor Program CRASHED !`r`n"
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
endif
endfunc



proc Switch_BOOT_Config

BOOT_Config_Flag = 0

WaitForCall ("The system is coming up, please wait...", "10", $NULLSTR, $NULLSTR, $NULLSTR, $NULLSTR, "1st BOOT Indicator: The system is coming up, please wait...")
WaitForCall ("Checking system RAM - press any key to stop test", "10", $NULLSTR, $NULLSTR, $NULLSTR, $NULLSTR, "2nd BOOT Indicator: Checking system RAM ...")

TransmitCall("^M", $NULLSTR, "Proceeding to STOP Brocade RAM Test!")
;TransmitCall(VK_ESCAPE, $NULLSTR, "Proceeding to STOP Brocade RAM Test!")
sendvkey VK_ESCAPE

WaitForCall ("host is alive", "30", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "Waiting for host is alive, BEFORE RESET PASSWORDS!")
WaitForCall ("setting passwd to defaults", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "setting passwd to defaults, BEFORE RESET PASSWORDS!")
WaitForCall ("time Bomb has been removed", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "time Bomb has been removed, BEFORE RESET PASSWORDS!")
WaitForCall ("Passwords have been reset. Please power cycle the switch.", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "Waiting for user to power cycle the switch!")
DialogBox_2("Comtek DialogBox2", "Please Power Cycle the Switch a 2nd Time !")

endproc
***********************************************************
Thanks, Willy113
 
I have done some rudimentary work on using memalloc/memset and other memory-related ASPECT commands to create pseduo-structures within scripts. You can find a couple different solutions on this page:


but I'm not sure it will help much in your situation.

Giving the script a quick look, it appears everything should work. What kind of problems are you running into?

Actually, looking at the script further and making a test run, it worked OK if I was just looking for a string of text, but did not work if I started adding optional arguments to the waitfor, which it looks like is the problem you are seeing as well.

I thought at first you could use macros (see #define in the help file) to get around this problem, but that wouldn't work since you would have to have a #define for every possible situation. In other words, what is happening when you have any options other than a string to wait for, all of those optional arguments are being lumped into the waitfor string and not firing as expected.

 
Hi Knob,

Yes, your closing statements are true, that now matter what coding tricks I played, I can never get the waitfor command to fire correctly after using any other parameters past the 1st string parameter as you mention ...

So with that said, and since you said that the memalloc/memset coding now won't work either, can you reccomend anything else to create such a function call ??

If not, can users send in bug reports and/or enhacement requests for future releases to Symantec ??

Is there going to be a 4.9 or 5.0 release anytime soon ?

Thanks, Willy113
 
Unfortunately, I can't really think of any good solution. Basically what you are tring to do is have a script create a script (or script commands). The only way I can think of to make that work would be to have a script that "writes" a second script.

As for Procomm, I am not aware of any plans by Symantec to release any further versions and/or patches.

 
Willy,

What are you trying to write this script for specifically?

Maybe there's another way to approach this.

 
Hi Cuberat,

I have used the ProcommPlus transmit and waitfor commands so much, that I would like to now write a "function call" with passed params to get rid of the thousands of hard coded lines of waitfor and transmit code.
The code example is above but using a function, I could concatante any of the 6 possible parameters to the wait string.

WaitForCall ("setting passwd to defaults", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "setting passwd to defaults, BEFORE RESET PASSWORDS!")

The problem that Knob points out and tried himself, is that only one string (the 1st param wait string) can be used or Procomm does not like the command string format.

Maybe there is a way to use a strfmt to construct or repair the string prior to passing it to the "waitfor" command ??

Any ideas or thoughts are welcome ...

- Willy113
 
I'll be a bit tied up until March. Got a lot of installations/upgrades going on. But I see knob's point. And he has sorta seen mine (to follow).

Your script would work....but you'd need seperate subroutines cleaning up the strings....or a script writing a script.

I'll tinker with this when I can. Writing a bunch of stuff right now for work. I'll try to zip this in.
 
Hello, is this what you need:

; Global var for WaitList() procedure
INTEGER WaitListStat = 0

;***************************************************************************
; Wait for a list of up to three strings
;
; Passed: INT: maximum # of seconds to wait
; STRING: Data string #1
; STRING: Data string #2
; STRING: Data string #3
;
; Use $NULLSTR to ignore a parameter.
;
; On Exit: Global WaitListStat = Data string # or 0
;***************************************************************************
PROC WaitList
PARAM INTEGER maxTime
PARAM STRING string1, string2, string3

INTEGER loopControl

#IFDEF ASPDEBUG
STRFMT S0 "WaitList on `"%s`" `"%s`" `"%s`"" string1 string2 string3
#ENDIF

WaitListStat = 0

WHEN TARGET 0 string1 CALL WaitListS1
WHEN TARGET 1 string2 CALL WaitListS2
WHEN TARGET 2 string3 CALL WaitListS3

FOR loopControl = 1 UPTO maxTime
PAUSE 1
IF WaitListStat
RETURN
ENDIF
ENDFOR

;; Failure, never received any. Clear them all and exit.
WHEN TARGET 0 CLEAR
WHEN TARGET 1 CLEAR
WHEN TARGET 2 CLEAR

ENDPROC

PROC WaitListS1
WHEN TARGET 0 CLEAR
WHEN TARGET 1 CLEAR
WHEN TARGET 2 CLEAR
WaitListStat = 1
ENDPROC

PROC WaitListS2
WHEN TARGET 0 CLEAR
WHEN TARGET 1 CLEAR
WHEN TARGET 2 CLEAR
WaitListStat = 2
ENDPROC

PROC WaitListS3
WHEN TARGET 0 CLEAR
WHEN TARGET 1 CLEAR
WHEN TARGET 2 CLEAR
WaitListStat = 3
ENDPROC
;***************************************************************************
;PROC SampleUsage
; ;; Wait for one of two prompts. No third prompt, so passing in $NULLSTR
; WaitList(30, "enter to continue...", "press X to exit:", $NULLSTR)
; if WaitListStat == 1
; ;; got the "enter to continue..." prompt
; elseif WaitListStat == 2
; ;; got the "press X to exit:" prompt
; elseif WaitListStat == 3
; ;; this one can't happen. We passed in $NULLSTR
; elseif WaitListStat == 0
; ;; didn't find any of the prompts, timed out after 30 seconds
; endif
;ENDPROC



greetings
Leo van der Kallen

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top