Use the scripting interface shell
This topic explains how to use the dmpmcli scripting interface, describes its syntax and properties, and provides examples of dmpmcli commands.
Run the shell
To run the scripting interface shell, open your command prompt and enter dmpmcli.
dmpmcli syntax
The shell has the following syntax:
dmpmcli
[-user <username>
-pass <password>
-dbname <database>
-host <server>
-dsn <dsn-name>
]
[-param <parameter file>
[-file <script file> [<script arguments>]]
[-help]
[-version]
where:
Parameter | Description |
---|---|
-user
<username>
|
Specifies a user ID that is registered on the Dimensions CM base database. |
-pass
<password>
|
Specifies the password for the user ID that you entered above. |
-dbname
<database>
|
Specifies the name of the base database. |
-host
<server>
|
Specifies the name of the Dimensions CM server. The <server> string may explicitly specify the port number of the Dimensions CM Listener, for example:
|
-dsn <dsn-name>
|
Specifies the connection string that enables you to connect to the database server for your Dimensions base database. |
-param <parameter file>
|
Specifies a file with connection parameters. For an example, see Specify connection parameters in a file. |
-file <script file> [<script arguments>]
|
Specifies a file with a script to run, and the script's (optional) arguments. |
-help
|
Displays the help for the dmpmcli syntax. |
-version
|
Displays the version of dmpmcli that you are running. |
Before the specified javascript source runs, the following actions take place:
-
dmpmcli overrides and specifies its own custom error reporting.
-
Dimensions CM defines the additional non-ECMA global javascript functions:
Copy codesystem
source
run
print
quit
version
help
exit -
The variable "arguments" are populated with the specified command-line arguments.
Specify connection parameters in a file
You can specify the connection parameters in a file rather than in the command line, for example:
-user dmsys
-pass <password>
-dbname intermediate
-host server1
-dsn PC50
Run scripts
You can use the -file
option to specify
a file containing a JavaScript script that is to be run.
If you do not specify a script, the interpreter
enters interactive mode, and the script source is read and run from standard
input until an EOF (End of File) character is detected (CTRL+Z on Win32 platforms and CTRL+D on UNIX platforms), or until you run
the quit()
or exit()
functions.
Examples of using dmpmcli
Use these examples to help you work with dmpmcli.
Example 1. Enter interactive mode:
dmpmcli -user dmsys -pass <password> -dbname intermediate -dsn PC50 -host dimhost
This command connects to the Dimensions CM
server node dimhost and enters interactive mode. To quit dmpmcli, use
the quit()
or exit()
functions.
Example 2. Run a script:
dmpmcli -user dmsys -pass <password> -dbname intermediate -dsn PC50 -host dimhost:5555 -file /home/dmsys/script/setupAttributes.js
This command connects to the Dimensions CM server node dimhost (assuming that the Dimensions CM Listener is listening on port 5555) and runs the following script:
/home/dmsys/script/setupAttributes.js
Example 3. Read connection information from a file:
dmpmcli -param /home/dmsys/connection.data -file /home/dmsys/script/setupAttributes.js
This command connects to the Dimensions CM server node identified by the connection information in the /home/dmsys/connection.data file, and runs the following script:
/home/dmsys/script/setupAttributes.js
Predefined properties
Scripts running in the dmpmcli shell have access to the following predefined top-level object properties:
Command | Description |
---|---|
arguments
|
An array containing the strings of all the arguments given at the command line when the shell was invoked. |
help()
|
Displays usage and help messages. |
defineClass(className)
|
Defines an extension using the Java class named with the string argument. Uses ScriptableObject.defineClass() |
run(["foo.js", "arg0", ...])
|
Runs the JavaScript source file specified by the first string in the argument, and passes the remaining arguments as that script's arguments. The parent environment is visible but cannot be modified. |
source(["foo.js", "arg0", ...])
|
Runs the JavaScript source file named by the first string in the argument, and passes the remaining arguments as that script's arguments. The parent environment is visible and can be modified. |
system(["cmd", ...])
|
Runs one or several native OS commands specified by the string argument. |
loadClass(className)
|
Loads a class named by the string argument. The class must be a script compiled to a class file. |
print([expr ...])
|
Evaluates and prints expressions. |
quit()
exit()
|
Quits the shell. The shell also quits in interactive mode if you enter an EOF character at the prompt. |
version([number])
|
Gets or sets the JavaScript version number. |
See also: