Fortran Library Reference

sh: Fast Execution of an sh Command

The function is called by:

INTEGER*4 sh

status = sh( 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: sh():


    character*18 string / 'ls > MyOwnFile.names' /
    INTEGER*4 status, sh
    status = sh( string )
    if ( status .ne. 0 ) stop 'sh: error'
    ...
    end

The function sh passes string to the sh shell as input, as if the string had been typed as a command.

The current process waits until the command terminates.

The forked process flushes all open files:

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

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

Note: string cannot be longer than 1,024 characters.