isCOBOL implementation of CALL SYSTEM and the iscobol.system.exec property


CALL SYSTEM and the iscobol.system.exec property

The SYSTEM library routine is used in a program to run an operating system command line as if it were executed from a command prompt, shell, script, batch file, or shortcut.

By default, the isCOBOL implementation of SYSTEM uses the java.lang.Runtime.exec() Java API.  This provides consistent behavior across all supported platforms.  For more information about this API, see this link.

However, this Java API has some limitations. For example, it does not support redirection of stdin, stdout, or stderr using the '<', '>', and '|' symbols within the command parameter string.  To address these limitations, isCOBOL provides a framework property, iscobol.system.exec, that can be used to customize the behavior of the SYSTEM routine.

Setting iscobol.system.exec to use a command interpreter

The iscobol.system.exec property specifies the name of a command to be executed when the SYSTEM routine is called. The SYSTEM routine constructs a command line using the value of the iscobol.system.exec property followed by the SYSTEM routine's parameter within double-quotes. For example, setting:

   iscobol.system.exec=sh -c

on UNIX/Linux and executing:

  call "SYSTEM" using "ls > out"

will cause the following command to be executed:

   sh -c "ls > out"

 For another example, setting:

   iscobol.system.exec=cmd /c

on Windows and executing:

   call "SYSTEM" using "dir > out"

will cause the following command to be executed:

   cmd /c "dir > out"

 

Setting iscobol.system.exec to access the C library system

Setting the iscobol.system.exec property to the special value "c" will cause isCOBOL to use the C library system() function instead of the Java API. This setting is provided for compatibility with other COBOLs.

For example, Micro Focus COBOL and ACUCOBOL-GT implement SYSTEM using the C library system() function. Set iscobol.system.exec=c to match the behavior of CALL "SYSTEM" in Micro Focus COBOL and ACUCOBOL-GT.

Note:
On Windows the C library system() function is in the MSVCRT.DLL. To load that DLL add the following property setting:

   iscobol.shared_library_list=msvcrt.dll

or add the following call to your program:

   call "msvcrt.dll"

 Note:
With
iscobol.system.exec=c, programs compiled with -cp option require the SYSTEM parameter to be null terminated (i.e. end with a low-value).
(Note that Micro Focus COBOL programs have the same requirement. So, if the program functioned correctly with Micro Focus COBOL then the code probably already null terminates the parameter.)

 

C$RUN and C$SYSTEM compatibility

isCOBOL also provides C$RUN and C$SYSTEM for compatibility with ACUCOBOL-GT.
Unlike the SYSTEM routine, C$RUN and C$SYSTEM are not affected by
iscobol.system.exec .


Article ID: 113
Created: November 26, 2009
Last Updated: November 19, 2026
Author: Support KB Author

Online URL: https://support.veryant.com/phpkb/article.php?id=113