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.
Remarks
Read-only numeric property.
If SecureCRT is started with no /ARG
command-line options, the crt.Arguments.Count
property is set to 0.
VBScript
Syntax
crt.Arguments.Count
Python
Syntax
crt.Arguments.Count
Description
Returns the argument data associated with each
/ARG
command-line option passed to SecureCRT.
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)
VBScript
Syntax
crt.Arguments.GetArg(number)
Example
#$language = "VBScript"
#$interface = "1.0"
Sub Main()
' This script should be run by SecureCRT that has two
' /ARG parameters for a hostname and port, for example:
'
' SecureCRT.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
Python
Syntax
crt.Arguments.GetArg(number)
Example
#$language = "Python"
#$interface = "1.0"
def main():
# This script assumes that SecureCRT was run with two
# /ARG parameters for a hostname and port, such as:
#
# SecureCRT.exe /ARG myhostname /ARG 5555
# Detect lack of arguments.
if crt.Arguments.Count != 2:
crt.Dialog.MessageBox(
"This script requires hostname and port " +
"arguments")
return
crt.Dialog.MessageBox(
"Connecting to hostname: " +
crt.Arguments[0])
crt.Dialog.MessageBox(
"Connecting to port: " +
crt.Arguments[1])
...
main()