Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-22-2015, 12:45 AM
Krimson714 Krimson714 is offline
Registered User
 
Join Date: Sep 2015
Posts: 3
One Password Multiple Scripts/Sessions

Hello,

I have a script that allows me to login to any device and use specific commands based on the session name including logging in with a saved username/password. The only problem with this is using a saved username/password where I work is not allowed.

In order for this script to be useful I would require a script that asks for the username/password when you launch it and saves that as a string that can then be called upon by other sessions that are also using a completely different script. I am trying to avoid the whole put your username/password in 50 times every couple minutes that seem to currently plague the work place and driving down productivity.

My initial thought was to create a script that asks for the username/password when I launch it and keep it in memory. Then upon launching the next script it auto pulls the username/password from the first script but I can't seem to figure out a way of doing this(outside saving it to a file)

1. I use python but can use another language if it fixes this issue

2. No username/Password can be saved to an external file and instead would need to be in memory

3. The password is different depending on what device you try to access so I don't think the PASSWORD section option would be useful either. That plus as new devices are added the whole SecureCRT Device/Session Options are uploaded to a share drive for everybody to redownload/import and I don't want to risk accidently username/passwords going across that way either.

4. No external python libraries can be downloaded, just what is default to python or VBScript that is used via SecureCRT.

Can this be done?
Reply With Quote
  #2  
Old 09-22-2015, 10:40 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Krimson74,

Thanks for the question. Security really isn't convenient is it. I have created a feature request to add the ability to somehow add or retrieve strings from memory via a scripting API interface in SecureCRT. Should we add this type of feature, we will post to this forum thread.

If you would like to be notified directly, please complete and submit the form at the following location:
Submit Feature Request
There is no simple solution to your goal. You could write your own service that would allow processes to access shared memory, but that would need to be secured in some way.

Another option would be to use a process level environment variable. The limitation of this approach is that you must use the same process for all of your SecureCRT sessions.

I have attached a couple of examples that illustrate how you can communicate between two scripts. You are welcome to expand on the concept in these scripts and use it to create your password solution.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730

Last edited by rtb; 09-22-2015 at 12:10 PM.
Reply With Quote
  #3  
Old 09-22-2015, 11:40 PM
Krimson714 Krimson714 is offline
Registered User
 
Join Date: Sep 2015
Posts: 3
Do you know if there is a workaround if I take out the underlined section of this statement?

"In order for this script to be useful I would require a script that asks for the username/password when you launch it and saves that as a string that can then be called upon by other sessions that are also using a completely different script"

Is there a way when I launch a new session to a device, that is just piggy backs off the already running script? I have no problem launching the script and then launching different sessions that all use the same instance of a script. Not 100% sure this will work but I was just wondering if it was even possible.
Reply With Quote
  #4  
Old 09-23-2015, 10:38 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Krimson714,

The process that I am referencing is the SecureCRT process. You would need to make sure that all connections that you establish are from the same SecureCRT process. The scripts you run will be related to the SecureCRT process. It is possible to configure SecureCRT to run with only one process. Perhaps this will help you accomplish your goal and you won't have to worry if you are using the same SecureCRT process for all connections and scripts.
You can make this change by editting the Global.ini file:
  1. Close all instances of SecureCRT. If changes are made to the Global.ini file while SecureCRT is running, the changes made will be undone when SecureCRT is restarted.
  2. Modify line in the Global.ini file as outlined below.

    The Global.ini file is located in the configuration folder. You can find the path to the configuration folder in the General category of the Global Options dialog in SecureCRT 7.1 and older. In SecureCRT 7.2 and newer, the path will be in the General / Configuration Paths category of the Global Options dialog.
  3. Save the Global.ini file and start SecureCRT.
The option in the .ini file that will need to be modified is as follows:
From:
D:"Single Instance"=00000000
To:
D:"Single Instance"=00000001
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 09-23-2015, 11:31 PM
Krimson714 Krimson714 is offline
Registered User
 
Join Date: Sep 2015
Posts: 3
Thank you,

Since I launch everything in tabs it auto uses the same SecureCRT instance. In my mind I thought the environment variables were locked to just the tabs and not the SecureCRT process. I was able to complete it using code similar to the below. The code below is just a reference for anybody else having an issue with this in the future that codes in python and is not the code I actually made. If anybody sees any potential improvements I can make to this please let me know.

Huge thanks for pointing this out to me and my workplace will surely appreciate it as well =]

Code:
#$language = "python"
#$interface = "1.0"

import os

try:
    os.environ["TEST_ENV_VAR"]
except:
    os.environ["TEST_ENV_VAR"] = crt.Dialog.Prompt("Enter the new ENV_VAR here", "Main Window", "", False)


Testvar = os.environ["TEST_ENV_VAR"]

crt.Dialog.MessageBox("The Testvar is: " + Testvar)

Last edited by jdev; 09-24-2015 at 09:20 AM. Reason: Corrected typos: ctr-->crt; "False"-->False
Reply With Quote
  #6  
Old 09-24-2015, 09:02 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Thanks for posting some example Python code, Krimson714.

I read through the Python documentation and it is not clear what type of environment variable that your code is creating. We suggested the VBScript code because it does have the ability to use a Process environment variable type which is not stored in a file. The System, User and Volatile environment variable types are all stored in files.

The example VBScript code posted previously does use the Volatile type, but you can change that to Process so a file is not used to store the environment variable.
__________________
--Todd

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


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 08:20 PM.