Arguments Object
From SecureCRT
Description
The Arguments object allows scripts to access arguments
that are passed to the script by one or more SecureCRT
/ARG command-line options.
Syntax
crt.Arguments.Property
crt.Arguments.Method(arg)
Remarks
The SecureCRT
/ARG command-line option allows
you to write common scripts where specific values used by the scripts
(such as a hostname or port) are passed to the script through the SecureCRT command line. Script
arguments are passed as an argument to each /ARG <argument>
option.
Arguments Object Properties and Methods
Description
Returns the number of arguments passed to SecureCRT using SecureCRT's
/ARG command-line option.
Syntax
crt.Arguments.Count
Remarks
Read-only numeric property.
If SecureCRT
is started with no /ARG command-line options, the crt.Arguments.Count
property is set to 0.
Description
Returns the argument data associated with each /ARG
command-line option passed to SecureCRT.
Syntax
crt.Arguments.GetArg(number)
Remarks
The GetArg method returns the data passed to SecureCRT. The first argument
passed to SecureCRT
is retrieved by calling GetArg(0). The last argument is retrieved
by passing the count returned by crt.Arguments.Count minus 1.
Note: The GetArg method is the default method on the Arguments object therefore it will be invoked implicitly if it is not named. This means the following two statements are equivalent:
MsgBox crt.Arguments.GetArg(0)
MsgBox crt.Arguments(0)
For example:
#$language = "VBScript"
#$interface = "1.0"
Sub Main()
' This script should be run by CRT that has two
' /ARG parameters for a hostname and port, for example:
'
' CRT.exe /ARG myhostname /ARG 5555
' Detect lack of arguments.
If crt.Arguments.Count <> 2 Then
MsgBox "This script requires hostname and port
arguments"
Exit Sub
End If
'
MsgBox "Connecting to hostname: " & crt.Arguments(0)
MsgBox "Connecting to port: " & crt.Arguments(1)
...
End Sub