|
From: Burke C. <bu...@bs...> - 2005-05-19 15:16:48
|
Burke Cabaniss asks: In a RedHat Linux environment I need to CALL bash and pass the commands it will execute; Linux programs and other scripts. With my current COBOL, this is CALL 'SYSTEM' USING [ dataname | literal ] . I would guess this might be done by a "canned" C executable, but am not a C programmer. I am a COBOL programmer in many environments for 40 years. `bash` capabilities greatly expand what I could do in previous environments. My COBOL has other useful CALL "canned" modules, such as one to return (pass) the string value of a bash environment variable, and the number and length of the USING parameters passed to a called COBOL program. Note that bash itself returns only an integer, if I understand. I do not find any of this treated in TC or other COBOL documentation. Please advise me about it. |
|
From: David E. <de...@us...> - 2005-05-19 19:48:28
|
Burke Cabaniss wrote: > Burke Cabaniss asks: > > In a RedHat Linux environment I need to CALL bash and > pass the commands it will execute; Linux programs and > other scripts. > With my current COBOL, this is > CALL 'SYSTEM' USING [ dataname | literal ] . > I would guess this might be done by a "canned" C executable, > but am not a C programmer. I am a COBOL programmer in many > environments for 40 years. > `bash` capabilities greatly expand what I could do in previous > environments. > > My COBOL has other useful CALL "canned" modules, such as one to return > (pass) the string value of a bash environment variable, and the number > and length of the USING parameters passed to a called COBOL program. > Note that bash itself returns only an integer, if I understand. > > I do not find any of this treated in TC or other COBOL documentation. > Please advise me about it. Yes you can call basically call any program or library function. Example: 01 VAR1. 05 FILLER X(15) VALUE 'ls -l some-dir' 05 FILLER X(01) VALUE x'00' ... CALL 'system' USING VAR1. Note that 'system' is C library call, and like any C string should be null terminated. Hope this helps. |
|
From: Burke C. <bu...@bs...> - 2005-05-19 20:32:27
|
Burke Cabaniss replied: I am very naive in your TC COBOL. You provide the same syntax I use. I simply did not try lower case 'system' versus traditional (in my programs) 'SYSTEM'. This resolves a big need for me in a simple way. Thank you very much. I also asked about a small thing (to me), which is passing back a string area from a system call. Your example writes `ls` to stdout, but one of my programs (for example) needs the output as a data table in COBOL. I can do this by directing output to a file, and then reading the file in COBOL. But you have parameters on the CALL statement that I do not understand. Is there a different name call library function, or a CALL parameter option that provides this ? If there are other call library functions, is there a place where I can read about them ? David Essex wrote: > Burke Cabaniss wrote: > > > Burke Cabaniss asks: > > > > In a RedHat Linux environment I need to CALL bash and > > pass the commands it will execute; Linux programs and > > other scripts. > > With my current COBOL, this is > > CALL 'SYSTEM' USING [ dataname | literal ] . > > I would guess this might be done by a "canned" C executable, > > but am not a C programmer. I am a COBOL programmer in many > > environments for 40 years. > > `bash` capabilities greatly expand what I could do in previous > > environments. > > > > My COBOL has other useful CALL "canned" modules, such as one to return > > (pass) the string value of a bash environment variable, and the number > > and length of the USING parameters passed to a called COBOL program. > > Note that bash itself returns only an integer, if I understand. > > > > I do not find any of this treated in TC or other COBOL documentation. > > Please advise me about it. > > Yes you can call basically call any program or library function. > > Example: > > 01 VAR1. > 05 FILLER X(15) VALUE 'ls -l some-dir' > 05 FILLER X(01) VALUE x'00' > ... > CALL 'system' USING VAR1. > > Note that 'system' is C library call, and like any C string should be > null terminated. > > Hope this helps. > > > |
|
From: David E. <de...@us...> - 2005-05-20 01:01:54
|
Burke Cabaniss wrote: > Burke Cabaniss replied: > > I am very naive in your TC COBOL. You provide the same syntax I use. I > simply did not try lower case 'system' versus traditional (in my > programs) 'SYSTEM'. UN*X and function calls (both C and TC) are case sensitive. The COBOL grammar and identifiers are NOT case sensitive. > I also asked about a small thing (to me), which is passing back a string > area from a system call. Your example writes `ls` to stdout, but one of > my programs (for example) needs the output as a data table in COBOL. I > can do this by directing output to a file, and then reading the file in > COBOL. But you have parameters on the CALL statement that I do not > understand. Is there a different name call library function, or a CALL > parameter option that provides this ? TC was enhanced to fit with the standard UN*X environment. For example DISPLAY/ACCEPT can be used to read/write to/from standard-output (and standard-error), standard-input. This feature enables a TC program to be used in a pipe. Example 1: ls -l | some-cobol-program | another-cobol-program > some-file Example 2: 01 VAR1. 05 FILLER X(25) VALUE 'ls -l > some-file'. 05 FILLER X(01) VALUE x'00'. ... CALL 'system' USING VAR1. ... OPEN INPUT FILEIN. ... READ FILEIN INTO ... In the above example, what ever is in the variable (identifier) VAR1, is passed as a parameter to the 'system' function, and in turn executed by the shell. To read/write UN*X type text files (variable length, with a <LF> as a record delimiter), just define a file as 'LINE-SEQUENTIAL'. To ensure that truncation does not occur, the work identifier should be larger than the maximum record length. > If there are other call library functions, is there a place where I can > read about them ? Perhaps I should clarify in mainframe-speak. Think of functions as the equivalent to COBOL sub-programs. Libraries are groups of sub-programs (functions) which are archived to form static and shared (dynamic) libraries. When a program executable is created, the link step resolves any dependencies to these calls, depending on which type of 'CALL' statement used. The 'CALL literal ...' statement is resolved at compile time. And the 'CALL identifier ...' statement is resolved dynamically at run-time, when the statement first is encountered. So basically you can call any function in any library. You can also create your own libraries consisting of C and COBOL sub-programs (functions). Unfortunately TC does not have much in the way of documentation. But the 'test.code' directories, enclosed with the compiler source code, contain many working examples. Hope this helps. |
|
From: Burke C. <bu...@bs...> - 2005-05-27 21:49:09
|
I can compile and run programs with htcobol. My question is about COBOL programs that CALL my other COBOL programs. I do not know about linking of executables, and am asking about general direction. I have about 30 large COBOL programs that run in a combination process. Some are CALL'ed and return, and some do not return. They "link" in my old terminology. The latter progressively and selectively CALL other of the programs. The COBOL I use has a "CALL PROGRAM [name]" statement that works like a CALL and then a CANCEL (of the caller). The COBOL I use finds programs by name in an object file directory, with no special "library" setup. I believe I want to put all of these programs in one or two dynamic link libraries. If two, one would be for "standard" functions that always return to the caller. If this is the right direction, please confirm. I can get the details of building dll's. |
|
From: David E. <de...@us...> - 2005-05-28 19:52:50
|
Burke Cabaniss wrote: > I can compile and run programs with htcobol. My question is about COBOL > programs that CALL my other COBOL programs. I do not know about linking > of executables, and am asking about general direction. > > I have about 30 large COBOL programs that run in a combination process. > Some are CALL'ed and return, and some do not return. They "link" in my > old terminology. The latter progressively and selectively CALL other of > the programs. The COBOL I use has a "CALL PROGRAM [name]" statement that > works like a CALL and then a CANCEL (of the caller). The COBOL I use > finds programs by name in an object file directory, with no special > "library" setup. Some COBOL compilers can create executables or special objects. The executables can be run from the command line. The 'special objects' are run using a special program which loads and then executes it (ex. COBOL object-name). This special program is really just a program linked with the COBOL run-time. The special objects are really just shared libraries (DLL's on Win32). Or as some people refer to them, modules. At this time, TC does not have this special program. But TC (GCC) can create binary objects, executables, libraries (shared and static). > I believe I want to put all of these programs in one or two dynamic link > libraries. If two, one would be for "standard" functions that always > return to the caller. If this is the right direction, please confirm. I > can get the details of building dll's. What I would do is create a library, with the "standard" functions that always return to the caller. For COBOL sources that do not return to the caller, I would create an executable for each one. For programs which call other COBOL programs, but do not return, you can use one of the 'exec*' C function call. Hope this helps. LINK: Perl Meets COBOL - A must read for main-frame programmers http://www.perl.com/pub/a/2000/05/cobol.html |
|
From: David E. <de...@us...> - 2005-05-30 15:44:41
|
Burke Cabaniss wrote: > ... > The COBOL I use has a "CALL PROGRAM [name]" statement that > works like a CALL and then a CANCEL (of the caller). The COBOL I use > finds programs by name in an object file directory, with no special > "library" setup. Some COBOL compilers can create executables or special objects. The 'special objects' are run using a special program which loads and then executes it. For example MF 'cobrun' and ACU 'runcbl'. I plan to add a program, called 'htcobrun', to CVS within the next few days. This will enable TC (sub)programs, compiled as modules (shared-libraries, DLLs), to be loaded and run. One of the advantages of this method, is that all COBOL programs can be compiled as modules. On UN*X platforms, a complete static versions of the TC run-time library can be enclosed in 'htcobrun', thus increasing program run performance. Would anyone like to try (test) this program ? If so let me know and I will forward the source and instructions. All comments and suggestions are welcomed. |