support: Customer Portal
Focused on delivering choice, investment protection and flexibility to organizations with valuable COBOL assets

Veryant Knowledge Base
Home > All Categories > Transitioning to isCOBOL > isCOBOL implementation of CALL SYSTEM and the iscobol.system.exec property
Question Title isCOBOL implementation of CALL SYSTEM and the iscobol.system.exec property
The SYSTEM library routine allows a program to run an operating system command line as if it was 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 mainly for its portability (i.e. it is supported and functions the same on all platforms). See 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.

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 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 Micro Focus COBOL and ACUCOBOL-GT behavior of CALL "SYSTEM".

On Windows the C library system() function is located in the MSVCRT.DLL. In order to load that DLL add the following property setting:


or add the following call to your program:

CALL "msvcrt.dll".

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.)

isCOBOL also provides C$RUN and C$SYSTEM for compatibility with ACUCOBOL-GT. This difference between these routines and SYSTEM is that SYSTEM runs the command synchronously so that the program waits for the command to complete before continuing. C$RUN runs the command asynchronously so that the program continues to run in parallel with the command. C$SYSTEM combines the functionality of SYSTEM and C$RUN and allows a command to be run synchronously or asynchronously depending on a "flags" parameter.

The iscobol.system.exec property does not affect C$RUN and C$SYSTEM. With isCOBOL C$RUN and C$SYSTEM always use the java.lang.Runtime.exec() Java API. To get identical behavior to ACUCOBOL-GT for these routines it is necessary to replace them with calls to SYSTEM or calls to your own subprogram that calls SYSTEM. For example, you can easily write your own C$RUN or C$SYSTEM routine in COBOL.

Threads in isCOBOL are real OS threads, not merely emulated threads such as in ACUCOBOL-GT. C$RUN could be implemented by calling SYSTEM on a separate thread. For example,

CALL THREAD "SYSTEM" USING "sort input.txt > sorted.txt".

will run the sort asynchronously. In other words, the CALL will return immediately without waiting for the sort to complete.

At the end of your program you can add the following line to wait for all threads to complete before exiting the process:


Here is an example program for UNIX/Linux:

    SET ENVIRONMENT "system.exec" to "c".
    CALL "SYSTEM" USING "ls -lrt * > ls.out.txt".
        "sort < ls.out.txt > ls.sort.txt".
And here is an example program for Windows:
    SET ENVIRONMENT "system.exec" to "c".
    CALL "msvcrt.dll".
    CALL "SYSTEM" USING "dir * > dir.out.txt".
        "sort < dir.out.txt > dir.sort.txt".
Note that in the above programs you could delete the SET ENVIRONMENT and the CALL "msvcrt.dll" statements and instead add the following lines to your file:

Authored by: Veryant Support This question has been viewed 13196 times so far.
Click Here to View all the questions in Transitioning to isCOBOL category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
How helpful was this article to you?
User Comments User Comments Add Comment
User Comment leon hermelin on Thu, Jun 17th, 2010 at 9:14 AM
Regarding of this point we can use also the START command to call a windows aplication if it isn’t in the path. i.e.: SET ENVIRONMENT "system.exec" to "c". CALL "msvcrt.dll". CALL THREAD "SYSTEM" USING "start excel mytable.xls". WAIT FOR LAST THREAD.
Related Questions Related Questions
  1. What are the options for using ActiveX controls?
  2. What compiler options and properties should I use for mainframe migrations with UniKix?
  3. Set iscobol.jdbc.autocommit=false when using ESQL in TP environments
Article Information Additional Information
Article Number: 113
Created: 2009-11-26 5:01 PM
Rating: 3 Stars
Article Options Article Options
Print Question Print this Question
Email Question Email Question to Friend
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
Bookmark Article
Subscribe to Article Subscribe to Article
Search Knowledge Base Search Knowledge Base


© Veryant - All Rights Reserved
Veryant and isCOBOL are trademarks or registered marks of Veryant in the United States and other countries. All other marks are the property of their respective owners.