VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   General (https://forums.vandyke.com/forumdisplay.php?f=11)
-   -   Environment Variable (https://forums.vandyke.com/showthread.php?t=10232)

he204035 01-05-2012 04:15 PM

Environment Variable
 
I have SecureCRT Version 6.7.3(build 292).

I have several sessions set up with a login script using an Environment variable and Session name:

HTML Code:

%VanDyke%%S.vbs
The way I have my Environment variable set on my local machine is:

HTML Code:

C:\Users\eheamay\AppData\Local\VanDyke Software\SecureCRT\Scripts\
But when I try to connect to the Session (whose Session name matches his own login script), SecureCRT tells me he can't find the script.

This has worked on earlier versions, so I wasn't sure if something has changed in this new version?


Thanks for your time.
:cool:

bgagnon 01-05-2012 05:38 PM

Hi he204035,

In my tests, this does work with both an environment variable and %S in SecureCRT 6.7.3.

What version of SecureCRT did you use previously where this worked correctly?

Can you verify the environment variable is still configured properly? (ie: type set at a command prompt)

Have you moved your session recently to a different folder within the Connect dialog?

bgagnon 01-09-2012 09:44 AM

Hi all,

As a note, there is now a pre-release build of SecureCRT available that will display the location SecureCRT is attempting (for the logon script) as opposed to the generic Failed to open script file dialog. If anyone wishes for me to make the pre-release build available to them, please write support@vandyke.com and include the following:
  • Whether 32-bit or 64-bit installer is needed (or both)
  • Whether SecureCRT only or SecureCRT/SecureFX
  • E-mail address used on VanDyke Software download account (if different from the one using to contact us)
  • Include "Attn Brenda - Forum Thread #10232" in the subject line

stevo 05-26-2021 07:48 PM

SecureCRT 7.1.2-316 not parsing Windows Environment Variables in Python Script
 
I'm on a system with a licensed version of SecureCRT 7.1.2 (x64 build 316) and it is not parsing the %USERNAME% Windows variable in a script.

Example I'm trying to use:
Code:

g_EnvUser = "%USERNAME%"
def main()
    crt.Dialog.MessageBox("Username is: " + g_EnvUser)
    result1 = crt.Dialog.MessageBox("Did it get the ENV VAR?", "Username is: " + g_EnvUser, ICON_QUESTION | BUTTON_YESNO | DEFBUTTON2 )
    if result1 == IDNO:
      return
main()

The previous reply from VanDyke to the original Poster indicates this works in SecureCRT 6.x. What am I doing wrong here?
Does it work? If so, what syntax should I be using?
I can't find any examples of using Environment Variables in Scripts.
Can you point me to any example scripts that do use Windows ENV Variables for SecureCRT 7.1.2?

Thanks.

bgagnon 05-27-2021 08:15 AM

Hi stevo,

I think you misunderstood the prior post.

That individual was setting the Logon script option in SecureCRT (Connection / Logon Actions) to use a path for which he had made an environment variable.

For example, let's say I create an environment variable in Windows named "stevo" and I make that path equal to C:\Temp\MyPythonScript\ and my session name is "server". Then in that directory I can have server.py as the script I want to run as my logon script. Then in the Logon script field I would have %stevo%%S.py. (I've tried to use color to show how the variables resolve.) :)

I've just tested this again and it does indeed work.

However, what you are trying to do I don't think is possible. The environment variables *within* a script are not resolved by Windows at runtime.


All times are GMT -6. The time now is 01:43 AM.