VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Persistent Variables (https://forums.vandyke.com/showthread.php?t=12446)

hawkandspit 08-18-2016 08:15 AM

Persistent Variables
 
Is there a way create persistent variables that will retain their value across script invocations or, preferably, across SecureCRT sessions and invocations?

For example, I have a 'repeat command' script that prompts or a command and repeat interval, then repeatedly issues the command to the Screen object some number of seconds after the command prompt returns. I want these parameters to be remembered the next time the script is invoked. Ideally, this would include the next time SecureCrt is launched.

Also, the value should be tied to the connection.

jdev 08-18-2016 11:10 AM

There are a number of options to consider for obtaining "persistent" values that you'd like to use now and in the future.

Saving information to a file might be an option. One idea would be a single flat file that would be read in each time your script runs. Each line would represent the session-specific information you desire to retain, with each piece of information separated by some delimiter, such as "||||" or "," or a tab character -- anything that wouldn't ever be part of the information you're trying to retain. The first element of each line could be the full "session path" so that you could easily identify the data that applies to the session you're currently operating on within your script.

You can also save information within the "description" of a saved session itself. This technique is demonstrated in an existing example script: Use Description Field As Script Arguments. This example is found among the many on our Script Examples "sticky" -- the top-most thread in the main Scripting forum.

If you're on Windows, you can also consider storing information in the Windows registry within a location of your choosing (Typically this would be somewhere in HKCU\Software\Your_Specific_Key_Name\...).

--Jake


All times are GMT -6. The time now is 11:33 AM.