INTEGER FUNCTION SYSTEMF( COMMAND_STRING ) CHARACTER*(*), INTENT(IN ) :: COMMAND_STRING
Note that you can build up quite complex commands by the use of semicolons, pipes, redirects, etc.
LEN( COMMAND_STRING )
is at most 4095
... INTEGER SYSTEMF EXTERNAL SYSTEMF ... INTEGER ISTAT ... !! Command: see if there are any files "/tmp/foo/*.ncf" !! change directory to /tmp/foo, then see if there are !! any files whose extension is ".ncf" !! ("ls -1" says list one per line, the semicolon strings !! the commands together into a compound command, and for "grep", !! we have to escape the period with a backslash (else it is a !! wild-card), and $ means at-end-of-line.) ISTAT = SYSTEMF( 'cd /tmp/foo ; ls -1 | grep "\.ncf$"' ) IF ( ISTAT .EQ. -1 ) THEN ! could not execute "ksh": WRITE( *,* ) & 'Error finding "ksh" to execute command' ELSE IF ( ISTAT .EQ. 0 ) THEN ! "grep" found matches: WRITE( *,* ) & 'Matches for ".ncf" were found' ELSE IF ( ISTAT .EQ. 1 ) THEN ! "grep" did not find matches: WRITE( *,* ) & 'No matches for ".ncf" found' ELSE ! "grep" had an I/O error: WRITE( *,* ) & 'I/O errror ', ISTAT, ' encountered' END IF ! end nested IF's on values of ISTAT ...
To: Models-3/EDSS I/O API: The Help Pages