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!

Script not spitting out what I put in 1

Status
Not open for further replies.

VoodooWillie

Technical User
May 13, 2003
2
US
I am new to writing Aspect scripts (started last week and learned or utilized parts of scripts from this forum) and may be missing something obvious, but the script I am working on is for logging into switch using a telnet session. The only thing that ever changes is the switch number I start on.

The dialog box comes up and I input the requested info and that's as far as it gets. The dialog box disappears and none of the info I entered is populated on the terminal.

Any assistance would be greatly appreciated.

Thanks in advance,

VW

Script is as follows:

#define TRUE 1

proc main

string uName, pWord, cOmc
integer Event
integer OMC = 4

dialogbox 0 8 20 264 169 3 "Automated Log In"
editbox 1 104 23 86 11 uName 15
editbox 2 105 44 86 11 pWord 15 MASKED
text 3 64 24 34 11 "User ID:" right
text 4 66 44 34 11 "Password:" right
text 5 109 69 46 11 "Choose OMC:" left
radiogroup 20 OMC
radiobutton 6 98 87 66 11 "Switch 1"
radiobutton 7 98 98 66 11 "Switch 2"
radiobutton 8 98 110 66 11 "Switch 3"
radiobutton 9 98 122 66 11 "Switch 4"
endgroup
pushbutton 10 38 151 40 13 "Ok" OK Default
pushbutton 11 186 151 40 13 "Cancel" CANCEL
enddialog

while TRUE
dlgevent 0 Event
switch Event
case 15
login(uName, pWord, cOMC)
;Evaluate radio group state
if OMC == 6
cOMC="1^M"
endif
if OMC == 7
cOMC="2^M"
endif
if OMC == 8
cOMC="3^M"
endif
if OMC == 9
cOMC="4^M"
endif
endcase
case -1
case 16
exitwhile
endcase
endswitch
endwhile
endproc

proc login

param string uName, pWord, cOMC
string sUserName, sPassWord, OMC

;waitfor "login: "
strfmt sUserName "%s^M" uName
transmit sUserName

waitfor "Password: "
strfmt sPassWord "%s^M" pWord
transmit sPassWord

waitfor "Please Enter Selection: >"
transmit "4^M"

waitfor "Please Enter Selection: >"
strfmt OMC "%s^M" cOMC
transmit OMC

waitfor ">"
transmit "CLI^M"

endproc
 
I found a number of errors in your script. The main problem is that your case number do not reflect your dialogbox control ids and you also have an unclosed case (case -1), but seeing as it is not an active dialogbox (just expecting string and integer input) it would be a lot easier to use a deadend dialogbox. See Example below

Code:
proc main

   string uName, pWord, cOmc
   integer Event
   integer OMC = 4

dialogbox 0 8 20 264 169 67 "Automated Log In"  ; Changed from type 3 to type 67
   editbox 1 104 23 86 11 uName 15 
   editbox 2 105 44 86 11 pWord 15 MASKED 
   text 3 64 24 34 11 "User ID:" right 
   text 4 66 44 34 11 "Password:" right 
   text 5 109 69 46 11 "Choose OMC:" left 
   radiogroup 20 OMC
      radiobutton 6 98 87 66 11 "Switch 1" 
      radiobutton 7 98 98 66 11 "Switch 2"
      radiobutton 8 98 110 66 11 "Switch 3" 
      radiobutton 9 98 122 66 11 "Switch 4" 
   endgroup
   pushbutton 10 38 151 40 13 "Ok" OK Default
   pushbutton 11 186 151 40 13 "Cancel" CANCEL
enddialog
   dlgevent 0 event
   if event == 10
      itoa OMC-5 cOMC            ; Subtract 5 from OMC and
                                 ; store as strvar cOMC
      login(uName, pWord, cOMC)  ; Call Login Procedure
   endif
endproc

proc login
   param string sUserName, sPassWord, sOMC
   
   ;waitfor "login: "
   transmit sUserName
   transmit "^M"
   
   waitfor "Password: "
   transmit sPassWord
   transmit "^M"

   waitfor "Please Enter Selection: >"
   transmit "4^M"
   
   waitfor "Please Enter Selection: >"
   transmit sOMC
   transmit "^M"
   
   waitfor ">"
   transmit "CLI^M"
endproc

 
mrnoisy,

The script you posted works great. Since I am new to this, I need all the help I can get. I really do appreciate it.

Thanks again,

VW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top