VMCMD

Execute a DCL command

 

 

VSupported on OpenVMS

 

xcall VMCMD(command, status, logflag)

Arguments

command

The DCL command to execute. The command must not include the DCL command prompt ($) and must not be more than 132 characters in length. (a)

status

A variable that will be loaded with one of the following values to indicate if the command was successfully executed: (n)

0 = The command was successful.

1 = The command was not an acceptable OpenVMS command or the command execution generated an error.

logflag

A variable or literal that controls whether or not the command execution is traced on the user’s terminal: (n)

0 = Disable logging.

nonzero = Enable logging.

Discussion

The VMCMD subroutine enables a Synergy program to execute any acceptable DCL command, including a request to execute an entire command file.

The VMCMD subroutine is the same as the SPAWN subroutine, except that it also returns a status and controls whether or not command execution is traced on the terminal.

The DCL command is executed in the context of a subprocess. Therefore, the requesting process must be permitted to use at least one subprocess (which requires the PRCLM resource parameter). The use of a subprocess is mandatory under OpenVMS because a process cannot execute two images simultaneously (in this case, those of the requestor and his or her command).

The subprocess is constrained to operate within the resource limits of the parent. However, note that resources consumed by the subprocess reduce those available to the parent.

Important

Because VMCMD requires the command line interpreter, if you are using xfServerPlus, you cannot XCALL this routine from within a shared image.

The VMCMD subroutine uses the LIB$SPAWN library routine to invoke the subprocess. (Refer to the OpenVMS RTL Library (LIB$) Manual for more information about LIB$SPAWN.) Upon return from LIB$SPAWN, the exit status is made available to the XSTAT subroutine. If an error is indicated by status, the error can be further qualified by calling XSTAT.

See also

Examples

Assuming that “WORK:” is a logical name set up to reference the intended directory and device, the subroutine below has the same effect as typing the text of cmd on a logged-in terminal. The Synergy program pauses while the DCL interpreter executes the command. If successful, a file named tmp.dta is created. The tmp.dta file contains a listing of the most recent versions of all files with the extension .ddf.

record
    cmd         ,a*,    "dir/output=tmp.dta/col=1 WORK:*.ddf;0"
    stat        ,d4
    log         ,d1,    0
proc
    .
    .
    .
    xcall vmcmd(cmd, stat, log)
    .
    .
    .