Training, Open Source computer languages

This is page http://www.wellho.net/forum/The-Tcl- ... guage/Setting-of-global-variables-in-expect.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Setting of global variables in expect

Posted by friend_chet (friend_chet), 16 January 2006
Hi

I am quite new to expect
I have a problem in hand

I am setting  a variable xyz  to a certain value say 85 in a procedure1  that is executed on machine1

.Now i want to use this value in another porcedure2 after i logon on to another machine2 through expect .

But I am not able to do it

What i am doing currently is That I am setting a variable
set xyz " "  
in the begining

then using it in procedure 1 on machine1 by declaring  it as  global  and then assigning it a value there.

and then using it in procedure 2 on machine 2
but xyz doesn't shows up with the value 85 there
?

Am i using the write procedure for using and setting  the variables

Thanks in advance





Posted by admin (Graham Ellis), 16 January 2006
If you declare a variable to be global in a proc in tcl (or expect) then that variable is the same as the variable of the same name in the main program that you're running.   So if you declare a variable to be global within two different procs that are running as part of the same program, they're one and the same.

However, global variables are only shared within a single program - it doesn't REALLY mean "Global" in the real world sense.  You can't declare a variable as being global in program X running on computer Y and have it turn up in program R running on computer T somewhere else in the world.  I think that's in effect what you're trying to do - sorry - it just doesn't work like that.



Posted by friend_chet (friend_chet), 16 January 2006
Hi

thnx for the quick reply.

Can u please help me out by giving any other method  or any other way for doing  such a thing .




Posted by admin (Graham Ellis), 16 January 2006
If I wanted to copy the contents of a variable from one machine to another when running two processes liked by expect, I would probably send the value as part of a string from the system on which it originated and expect it on the destination machine, saving it into a variable from [b]expect_out[b].

That's not a very friendly / maintainable / extensible option and if you have a lot of data involved and want it shared both ways, you would to better to look at storing and recovering data into a commonly accessible location such as a MySQL database or even on a website.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho