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!

Passing a string variable from a child script back to the parent

Status
Not open for further replies.

matt1981m

Technical User
Jul 1, 2006
32
US
I know it is possible to send a variable from a Parent to the Child script using the [execute "scriptname.was" SHARED] command, but is it possible to have a string variable pass from the child back to the parent??? Basically what is happening is I use one address, username and password to get a list of different MTSO's that I use.... I then select one of the MTSO's from the list. I have created a script that contains the username and password info. Then I have another that selects the individual switch. The reason I dont have them combined is per I change my password frequently, and I don't want to update every single switch script. I have a working script setup right now, but it is very slow.... I believe this would speed it up. Below is what I believe would be the logical format for the script, but it doesn't work...

;this is the "switch" portion of the script
proc main
string pswd,usrnm
waitfor "Login:"
execute "pw_test.was" SHARED
transmit usrnm
transmit "^J^M"
waitfor "Password:"
transmit pswd
transmit "^J^M"
when QUIET 4 call relogin
transmit "5^J^M"
pwtitlebar "NAME OF SWITCH" PERMANENT
when CLEAR
waitfor ">"
waitfor ">"
waitfor ">"
endproc

proc relogin
HANGUP
DIAL TELNET "Appropriate Connection"
call main
halt
endproc


;this is the pw_test.was file
proc main
string usrnm = "myusername"
string pswd = "mypassword"
pwtitlebar "Logging in..." PERMANENT
endproc

....I would like to get this to work... If I cant do it this way, can I do a file query and just have the username and password in that file, or 2 separate files.... I think that would take longer though, and i dont want to have that file open while it is loading the info...
 
Yes, you can pass values via the predefined global variables that ASPECT use. s0 through s9 for strings, i0 through i9 for integers, f0 through f9 for floats, and l0 through l9 for longs. Here's a quick example:

test.was
proc main
s0 = "foo"

execute "test2.wax"
usermsg "%s" s0
endproc

test2.was
proc main
s0 = "bar"
endproc

The modified value from the test2 script is present back in the main parent script when execution returns to it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top