Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2012, 04:15 PM
he204035 he204035 is offline
Registered User
 
Join Date: Mar 2011
Posts: 8
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.
Reply With Quote
  #2  
Old 01-05-2012, 05:38 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 01-09-2012, 09:44 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #4  
Old 05-26-2021, 07:48 PM
stevo stevo is offline
Registered User
 
Join Date: Jun 2016
Posts: 2
Exclamation 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.
Reply With Quote
  #5  
Old 05-27-2021, 08:15 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:23 PM.