Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Old 02-10-2018, 01:15 AM
kingzleshe kingzleshe is offline
Registered User
Join Date: Feb 2018
Posts: 26
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"

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

vlanID = crt.Dialog.Prompt("Enter VLAN ID:", "VLAN ID")
crt.Screen.Send "vlan create vlan " & vlanID & chr(13)
Reply With Quote
Old 02-11-2018, 08:49 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
Join Date: Jan 2017
Posts: 654
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:

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.

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.

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?

VanDyke Software
Technical Support
(505) 332-5730
Reply With Quote
Old 02-12-2018, 08:51 AM
kingzleshe kingzleshe is offline
Registered User
Join Date: Feb 2018
Posts: 26
Thumbs up

It's been very helpful.
Reply With Quote

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 01:18 AM.