| |||||||||||
Setting of global variables in expect Posted by friend_chet (friend_chet), 16 January 2006 HiI 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.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |