Using 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.

In this topic:

- Running_the_Shell

- dmpmcli_Syntax

- Examples_of_Using_dmpmcli

- Predefined_Properties

Running 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: -host servername:5555
-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 containing connection parameters. For an example, see Specifying_Connection_Parameters_in_a_File.
-file <script file> <script arguments>] | Specifies a file containing a script to be executed, and the script's (optional) arguments.
-help | Displays 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:

- system

- source

- run

- print

- quit

- version

- help

- exit

- The variable "arguments" are populated with the specified command-line arguments.

Specifying 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

Executing 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 you invoke the `exit()` or `quit()` functions.

Examples of Using dmpmcli

Entering interactive mode:

dmpmcli -user dmsys -pass <password> -dbname intermediate -dsn PC50 -host dimhost

connects to the Dimensions CM server node dimhost and enters interactive mode. To quit dmpmcli, use the or `quit()` or `exit()` functions.

Executing a script:

dmpmcli -user dmsys -pass <password> -dbname intermediate -dsn PC50 -host dimhost:5555 -file /home/dmsys/script/setupAttributes.js

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

Reading connection information from a file:

dmpmcli -param /home/dmsys/connection.data -file /home/dmsys/script/setupAttributes.js

connects to the Dimensions server node identified by the connection information in this file:

/home/dmsys/connection.data,

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 will also quit in interactive mode if you enter an EOF character at the prompt.
version([number]) | Gets or sets the JavaScript version number.

Related Topics

Using the Object Model

Example Java Scripts