Executes an operating system command as a spawned child process and waits for the child process to return.
||Optional The command or program to be executed as a child process, specified as a quoted string. If you omit oscommand, $ZF(-1) launches the operating system shell.
permits a Caché process to invoke a command of the host operating system. It executes the program or command specified in oscommand
as a spawned child process from the current console. It waits for the process to return. It returns the child process exit status.
returns the following status codes:
It returns 0 if the child process executed successfully.
It returns a positive integer based on the exit status error code issued by the operating system shell. This integer exit status code value is determined by the host operating system. For example, for most Windows command syntax errors, $ZF(-1)
It returns -1 if the child process could not be forked.
waits for a response from the spawned child process, you cannot successfully shut down Caché while the child process is executing.
If a pathname supplied in oscommand
contains a space character, pathname handling is platform-dependent. Windows and UNIX® permit space characters in pathnames, but the entire pathname containing spaces must be enclosed in an additional set of double quote (") characters. This is in accordance with the Windows cmd /c
statement. For further details, specify cmd /?
at the Windows command prompt.
is unable to spawn a process, it generates a <FUNCTION> error.
These two functions are in most respects identical. They differ in the following way:
suspends execution of the current process while awaiting completion of the spawned child process. It receives status information from the spawned process, which it returns as an exit status code (an integer value) when the spawned process completes.
does not suspend execution of the current process. It immediately returns a status value upon spawning the child process. Because it does not await completion of the spawned child process it cannot receive status information from that process.
The following Windows example executes a user-written program, in this case displaying the contents of a .txt file. It uses NormalizeFilenameWithSpaces()
to handle a pathname for $ZF(-1)
. A pathname containing spaces is handled as appropriate for the host platform. A pathname that does not contain spaces is passed through unchanged. $ZF(-1)
returns the Windows shell exit status of 0 if the specified file could be accessed, or 1 if the file access failed:
SET fname="C:\My Test.txt"
The following Windows example invokes the Windows operating system SOL command. SOL opens a window that displays the Solitaire game provided with the Windows operating system. Upon closing of the Solitaire interactive window, $ZF(-1)
returns the Windows shell exit status of 0, indicating success:
The following Windows example invokes a non-existent Windows operating system command. $ZF(-1)
returns the Windows shell exit status of 1, indicating a syntax error:
The following Windows example invokes a Windows operating system command, specifying a non-existent network name. $ZF(-1)
returns the Windows shell exit error status of 2:
WRITE $ZF(-1,"NET USE :k \\bogusname")