SYSTEM

Portability Function: Sends a command to the shell as if it had been typed at the command line.

Module: USE DFPORT

Syntax

result = SYSTEM (string)

string
(Input) Character*(*). Operating system command.

Results:

The result is of type INTEGER(4). The result is the exit status of the shell command. If -1, use IERRNO to retrieve the error. Errors can be one of the following:

On WNT systems, the calling process waits until the command terminates. On W9* systems, the calling process does not currently wait in all cases; however, this may change in future implementations. To insure compatibility and consistent behavior, an image can be invoked directly by using the Win32 API CreateProcess( ) in your Fortran code.

Commands run with the SYSTEM routine are run in a separate shell. Defaults set with the SYSTEM function, such as current working directory or environment variables, do not affect the environment the calling program runs in.

The command line character limit for the SYSTEM function is the same limit that your operating system command interpreter accepts.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: SYSTEMQQ

Example

   USE DFPORT
   INTEGER(4) I, errnum
   I = SYSTEM("dir > file.lst")
   If (I .eq. -1) then
     errnum = ierrno( )
     print *, 'Error ', errnum
   end if
   END