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 11-10-2017, 03:16 PM
Hang Hang is offline
Registered User
 
Join Date: Jul 2016
Posts: 6
user input

Is there a way in SecureCRT where I can ask the user for inputs and store that inputs in a variable for use later in a script? I want to do this without a message box popping up.

For ex:

"Please slot number:", slotNum

"Please enter port number: ", portNum

crt.Screen.Send("show port " + slotNum + "/" "portNum \n"


Thanks,
Reply With Quote
  #2  
Old 11-10-2017, 03:48 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 269
Hi Hang,

Typically when prompting for user input you would use something like the below code.

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

slotNum = crt.Dialog.Prompt ("Please slot number:")
portNum = crt.Dialog.Prompt ("Please enter port number: ")

crt.Screen.Send "echo show port " & slotNum & "/" & portNum & vbcr
The Prompt method does however use a popup. Can you give me a better idea of where you would like your user to see and enter the prompt?

If you don't want to use a popup perhaps use of the Arguments method would be a better option for you. As an example you could use something like below.

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

slotNum = crt.Arguments(0)
portNum = crt.Arguments(1)

crt.Screen.Send "echo show port " & slotNum & "/" & portNum & vbcr
You could then launch SecureCRT from either the command line with the arguments defined or by using SecureCRT's Button Bar.

The command line option to launch a script with options would look like:

Code:
SecureCRT.exe /SCRIPT c:\Path\To\Script\Arguments.vbs /S SessionName /arg arg0 /arg arg1
Information on using the Button Bar can be found here.

You would want to setup your button similar to this example.
Attached Images
File Type: png ButtonBarArguments.png (25.7 KB, 36 views)
__________________
Thanks,
--Eric

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

Last edited by ekoranyi; 11-10-2017 at 03:51 PM.
Reply With Quote
  #3  
Old 11-10-2017, 04:10 PM
Hang Hang is offline
Registered User
 
Join Date: Jul 2016
Posts: 6
Hi Eric,

Thanks for the suggestion.

I forgot to mention I am using Python to do most of my scripting.

Does the argument method works in Python?

I would like to ask the user in the console menu. I want the question to be on top of the command being sent to the screen. So, if I have a question "Please enter your slot#", it would display that question on top of the console and not sent to the console like using the crt.Screen.Sent("question"). Then the user would put in an answer, I would capture that in a variable. And then another question will be ask, etc...

I am planning on to ask multiple times, the input will not always be a number, it would get very annoying if a pop up message show up each time I ask a question.

Thanks,
Reply With Quote
  #4  
Old 11-10-2017, 04:43 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 269
Hi Hang,

Yes, the use of arguments works in Python as well.

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

slotNum = crt.Arguments[0]
portNum = crt.Arguments[1]

crt.Screen.Send("echo show port " + slotNum + "/" + portNum + "\r")
SecureCRT does not currently support prompting for and getting input in a script via the terminal window. I have created a feature request in our database of SecureCRT requests for you.

Should a version of SecureCRT that supports this functionality become available we'll be sure to let you know.
__________________
Thanks,
--Eric

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 04:26 PM.