! command

The ! command creates a UNIX shell and executes any UNIX command.

Note: For Windows: Running a Windows program that requires input results in a hung program.






The UNIX command parameter is any UNIX command. A shell is created and the command submitted to it. If the UNIX command parameter is omitted, a shell is pushed. D3 messages are held until the UNIX command is complete. If more than one message is received, only the last one displays when returning to TCL.

Each time the ! or sh command is invoked, a new shell is pushed on top of TCL. Control is transferred to this shell. Pressing CTRL+D returns control to TCL.

Note: The syntax for this command does not require a space after the ! character.

Macros in the master dictionary make almost all UNIX commands available from D3. Listed below are two useful tips on using this facility:

  • Avoid creating an intermediate shell process.

    The sh command uses the system UNIX library call to execute the UNIX command. This command creates a new process, which executes the default shell /bin/sh and passes the string to this new shell. In turn, this new process creates another shell process, which does an exec of the UNIX command. The intermediate process, the one created by the system, is normally useless. The macro structure below avoids the creation of a third process:

    01 n
    02 !exec command

    The exec shell command replaces the second process.

  • Changing and setting environment variables.

    After a shell is created, it inherits environment variables from the D3 process. It is possible to change any variable in the macro itself. For example, consider this example:

    01 n
    02 !cd /usr/mydir; TERM=ibm3151; export TERM; exec sh

    This macro changes the default directory, sets a new (UNIX) terminal type and finally executes a shell. By typing env in this new shell, the new setting is shown. To permanently set environment variables, use the TCL environ.