Fortran Library Reference

system: Execute a System Command

The function is called by:

INTEGER*4 system

status = system( string )

string

character*n

Input 

String containing command to do  

Return value 

INTEGER*4

Output 

Exit status of the shell executed. See wait(2) for an explanation of this value.

Example: system():


    character*8 string / 'ls s*' /
    INTEGER*4 status, system
    status = system( string )
    if ( status .ne. 0 ) stop 'system: error'
    end

The function system passes string to your shell as input, as if the string had been typed as a command. Note: string cannot be longer than 1024 characters.

If system can find the environment variable SHELL, then system uses the value of SHELL as the command interpreter (shell); otherwise, it uses sh(1).

The current process waits until the command terminates.

Historically, cc and f77 developed with different assumptions:

The system function flushes all open files:

See also: execve(2), wait(2), and system(3).

The system() function is not MT-safe. Do not call it from multithreaded or parallelized programs.