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 02-10-2018, 02:15 AM
kingzleshe kingzleshe is offline
Registered User
 
Join Date: Feb 2018
Posts: 4
how to prompt function

HI guys
Base on the example as follow,I try to modify it for my needs. But it doesn't work.Any help would be appreciated.
BTW:I am a noob

sfpshow 42 -f -link -force | grep -e RX -e TX
I need to change 42 to variable:

Port = crt.Dialog.Prompt("Enter Port:", "Port")
crt.Screen.Send "sfpshow " & Port & chr(13) "| grep -e RX -e TX -e Port"


VBScript
Syntax
crt.Dialog.Prompt(message [, title [, default [, isPassword ]]])
Example
Code:
Dim pass
pass = crt.Dialog.Prompt("Enter your password:", "Logon Script", "", True)
If pass = "" Then
' User clicked Cancel button
Else
' User added data
End If
For your use it may look something like:

Code:
vlanID = crt.Dialog.Prompt("Enter VLAN ID:", "VLAN ID")
crt.Screen.Send "vlan create vlan " & vlanID & chr(13)
Reply With Quote
  #2  
Old 02-11-2018, 09:49 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 559
Hi kingzleshe,

I believe the issue you're running into is the placement of the chr(13). chr(13) is the ascii character code for carriage return, or pressing Enter. In this case it appears that we are telling SecureCRT to "press Enter" after your variable then to send the second half of the command.

If the command you need is:

Code:
sfpshow 42 -f -link -force | grep -e RX -e TX
It could be modified to use a variable by replacing just the portion that needs to change.

Code:
crt.Screen.Send "sfpshow " & Port & " -f -link -force | grep -e RX -e TX"
If you need to "press Enter" after the command is sent to the screen you would add the chr(13) to the end.

Code:
crt.Screen.Send "sfpshow " & Port & " -f -link -force | grep -e RX -e TX" & chr(13)
We've put together A Guide to Using VBScript in SecureCRT that may help you get started. Another very useful tool is SecureCRT's Help. It contains reference material for available Properties and Methods. I find the easiest way to get to the information is to choose Help Topics from the main Help drop down menu. In the Contents tab choose Scripting then Script Objects Reference.

Does this help get you the functionality you're looking for?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 02-12-2018, 09:51 AM
kingzleshe kingzleshe is offline
Registered User
 
Join Date: Feb 2018
Posts: 4
Thumbs up

Thanks!
It's been very helpful.
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 03:28 AM.