The System Management Interface Tool (SMIT) can use several descriptors defined in its objects to get the information, such as current run time values, required to continue through the SMIT interface structure. Each of these descriptors is assigned some form of command string to run and retrieve the needed data.
The descriptors that can be set to a command for discovery of required information are:
SMIT executes a command string specified by a cmd_to_list, cmd_to_classify, or cmd_to_discover descriptor by first creating a child process. The strerr (standard error) and standard output of the child process are redirected to SMIT via pipes. SMIT next executes a setenv("ENV=") subroutine in the child process to prevent commands specified in the $HOME/.env file of the user from being run automatically when a new shell is invoked. Finally, SMIT calls the execl system subroutine to start a new ksh shell, using the command string as the ksh -c parameter value. If the exit value is not 0, SMIT notifies the user that the command failed.
SMIT makes the path names of the log files and the settings of the command line verbose, trace, and debug flags available in the shell environment of the commands it runs. These values are provided via the following environment variables:
The presence or absence of the corresponding flag is indicated by a value of 0 or 1, respectively.
An easy way to view the current settings is to invoke the shell function after starting SMIT and then run the command string env | grep _SMIT.
All writes to the log files should be done as appends and should be immediately followed by flushes unless this occurs automatically.
When SMIT puts up a dialog, it gets the sm_cmd_hdr (dialog header) object and its associated dialog body (one or more sm_cmd_opt objects) from the object repository. However, the sm_cmd_opt objects can also be initialized with current run time values. If the sm_cmd_hdr.cmd_to_discover field is not empty ("" ), SMIT runs the command specified in the field to obtain current run time values.
Any valid ksh command string can be used as a cmd_to_discover descriptor value. The command should generate the following output format as its standard output:
#name_1:name_2: ... :name_n\n value_1:value_2: ... :value_n
In the standard output of a command, the first character is always a # (pound sign), a \n (new line character) is always present to separate the name line from the value line, multiple names and values are separated by : (colons), and any name or value can be an empty string (which in the output format appears as two colons with no space between them). SMIT maintains an internal current value set in this format that is used to pass name-value pairs from one screen to the next.
Note: If the value includes a : (colon), the : must be preceded by #! (pound sign, exclamation point). Otherwise, SMIT reads the : (colon) as a field separator.
When SMIT runs a command specified in a cmd_to_discover field, it captures the stdout of the command and loads these name-value pairs (name_1 and value_1 name_2 and value_2 , and so on) into the disp_values and aix_values descriptors of the sm_cmd_opt (dialog command option) objects by matching each name to a sm_cmd_opt.disc_field_name descriptor in each sm_cmd_opt object.
For a sm_cmd_opt (dialog command option) object that displays a value from a preceding selector, the disc_field_name descriptor for the dialog command option object must be set to "_rawname" or "_cookedname" (or whatever alternate name was used to override the default name) to indicate which value to use. In this case, the disc_field_name descriptor of the sm_cmd_opt (dialog command option) object should normally be a no-entry field. If a particular value should always be passed to the command, the required descriptor for the sm_cmd_opt (dialog command option) object must be set to y (yes), or one of the other alternatives.
A special case of option ring field initialization permits the current value for a cmd_to_discover descriptor (that is, any name-value pair from the current value set of a dialog) of a ring entry field to specify which pre-defined ring value to use as the default or initial value for the corresponding entry field. At dialog initialization time, when a dialog entry field matches a name in the current value set of the dialog (via sm_cmd_opt.disc_field_name), a check is made to determine if it is an option ring field (sm_cmd_opt.op_type = "r") and if it has predefined ring values (sm_cmd_opt.aix_values != ""). If so, this set of option ring values is compared with the current value for disc_field_name from the current value set. If a match is found, the matched option ring value becomes the default ring value (sm_cmd_opt.value_index is set to its index). The corresponding translated value (sm_cmd_opt.disp_values), if available, is displayed. If no match is found, the error is reported and the current value becomes the default and only value for the ring.
In many cases, discovery commands already exist. In the devices and storage areas, the general paradigms of add, remove, change, and show exist. For example, to add (mk), a dialog is needed to solicit characteristics. The dialog can have as its discovery command the show (ls) command with a parameter that requests default values. SMIT uses the standard output of the show (ls) command to fill in the suggested defaults. However, for objects with default values that are constants known at development time (that is, that are not based on the current state of a given machine), the defaults can be initialized in the dialog records themselves; in this case, no cmd_to_discover is needed. The dialog is then displayed. When all fields are filled in and the dialog is committed, the add (mk) command is executed.
As another example, a change (ch) dialog can have as its discovery command a show (ls) command to get current values for a given instance such as a particular device. SMIT uses the standard output of the show (ls) command to fill in the values before displaying the dialog. The show (ls) command used for discovery in this instance can be the same as the one used for discovery in the add (mk) example, except with a slightly different set of options.
Associated with each occurrence of a cmd_to_discover, cmd_to_classify, or cmd_to_list descriptor is a second descriptor that defines the postfix for the command string defined by the cmd_to_discover, cmd_to_classify, or cmd_to_list descriptor. The postfix is a character string defining the flags and parameters that are appended to the command before it is executed.
The descriptors that can be used to define a postfix to be appended to a command are:
The following is an example of how the postfix descriptors are used to specify parameter flags and values. The * (asterisk) in the example can be list , classify , or discover .
Assume that cmd_to_* equals "DEMO -a" , that cmd_to_*_postfix equals "-l _rawname -n stuff -R _cookedname" , and that the current value set is:
Then the constructed command string would be:
DEMO -a -l 'gigatronicundulator' -n '47' -R 'parallel'
Surrounding '' (single-quotation marks) can be added around postfix descriptor values to permit handling of parameter values with embedded spaces.
System Management Interface Tool (SMIT) Overview for Programmers.
For more information about programming SMIT, see Understanding SMIT Screen Types, Understanding SMIT Object Classes, Understanding SMIT Aliases and FastPaths, and Understanding SMIT Command Generation and Execution.
Adding Tasks to the SMIT Database, Debugging SMIT Database Extensions, Creating SMIT Help Information for a NewTask.
The ksh command, smit command.