Using CLI

The Command Line Interface (CLI) can be used to submit IBM Sterling Connect:Direct Processes and commands from a native command line environment.

Starting the CLI

Procedure

  1. If you have not defined the NDMAPICFG environment variable, type the following command for the appropriate shell, where d_dir is the path to the IBM® Connect:Direct subdirectory.

    In the C shell:

    % setenv NDMAPICFG d_dir/ndm/cfg/cliapi/ndmapi.cfg

    In the Bourne or Korn shell:

    $ NDMAPICFG=d_dir/ndm/cfg/cliapi/ndmapi.cfg
    $ export NDMAPICFG
  2. Type the following command to invoke IBM Connect:Direct CLI. Type options as required:
    $ direct [-P string -s -t n -e nn -n name -p nnnnn -x -r -h -z]

Stopping the CLI

Procedure

Stop the CLI operation by typing Control-D or quit at the prompt.

CLI Commands

Refer to the following table for a description of the command options and sample command entries:

Option Description Value Sample Command Entry
-P Identifies the custom string to use at the command line prompt.

If the prompt string includes spaces or special characters, enclose it in single or double quotation marks.

The prompt string can also be specified in the ndmapi.cfg file. If a prompt string is specified on the command line and in the ndmapi.cfg file, -P takes precedence.

When the default prompt (“Direct”) is overridden, the new prompt string is shown at the command line prompt and in the welcome banner display.

text string

Up to 32 characters.

$ direct -PNewPrompt

$ direct -P”Test CD on Medea”

-s Suppresses standard output. Use this option to view only the completion status of a command. none $ direct -s
-t n Enables the CLI/API trace option. The level number, n, identifies the level of detail in the trace output. 1 | 2 | 4

Specify one of the following level numbers:

1—Provides function entry and function exit. This is the default.

2—Provides function entry and exits and basic diagnostic information, such as displaying values of internal data structures at key points in the execution flow.

4—Enables a full trace. All diagnostic information is displayed.

$ direct -t 4
-e nn Defines the error level above which the CLI automatically exits. If the returned error code is greater than the error level specified, the CLI automatically exits.

Use this command within shell scripts.

This parameter prevents unwanted execution of commands following a command that generates an error above the specified level.

When the CLI terminates, it returns a UNIX exit code that can be tested by the shell.

0 | 4 | 8 | 16

Valid values in the error level code are:

0—Indicates successful completion.

4—Indicates warning.

8—Indicates error.

16—Indicates catastrophic error.

$ direct -e 16
-n name Identifies the host name of the computer where the IBM Connect:Direct server (PMGR) is running.
Note: Invoking direct with -p or -n overrides the settings in the ndmapi.cfg file.
IBM Connect:Direct host name $ direct -n hostname
-p nnnnn Identifies the communications port number for the IBM Connect:Direct node.
Note: Invoking direct with -p or -n overrides the settings in the ndmapi.cfg file.
1024–65535. The format is nnnnn. $ direct -p 2222
-x Displays command input on standard out. Use this command when debugging scripts. none $ direct -x
-r Makes the Process number available to user-written shell scripts. The CLI displays a special string, _CDPNUM_ followed by a space, followed by the Process number. none $direct -r | grep “_CDPNUM_”
-h Displays command usage information if a IBM Connect:Direct command is typed incorrectly. none $ direct -h
-z Appends a newline character after a prompt. none $ direct -z
-a

Dynamically enables client authentication tracing, intended to assist in investigating CLI connection or authorization failures. This trace is captured in the d_dir/ndm/bin/ndmauthc.log file.

The trace option -a can be used independently of the existing -t CLI trace option.

none $ direct -a

CLI Job Control

IBM Connect:Direct enables you to switch the CLI Process between the foreground and the background in shells that support job control. This capability enables you to edit the text of saved Processes, issue UNIX commands, and resolve Process errors without exiting and reentering the CLI. Use the following commands to switch the CLI Process:

  • Press the suspend character (Control-Z) to stop or suspend the CLI Process.
  • Issue the fg command to move the CLI Process to the foreground.
Note: If you experience problems with job control, contact your system administrator for suggestions on additional UNIX commands to use.

CLI History Commands

IBM Connect:Direct enables you to use the history commands available with UNIX. History commands do not need the semicolon (;) at the end of the command. The following table lists the available history commands:

Command Description
!! Repeat the last command one time.
!#n Set the number of commands to store in the history buffer. The default history buffer size is 50 commands.
!n Repeat command number <n> in the history buffer.
!<string> Repeat command beginning with the string <string>.
!? List the contents of the history buffer.