Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a UNIX Shell Script from a Cobol program

Status
Not open for further replies.

jewilson2

Technical User
Feb 7, 2002
71
0
0
US
Hello,
I think I'm on the right track with this, but it will not compile. Could you folks take a look and tell me what might be wrong?

PROCEDURE DEFINITION

CALL "SYSTEM" USING WS-COMMAND.

WORKING STORAGE

01 WS-COMMAND-LINE.
03 WS-COMMAND-COM PIC X(25) VALUE "/test/glint/glint.sh ".

That being the absolute path to the script itself.

When trying to compile I get the errors:
( 7): Incomplete Quote, Error in TokRead
syntax error line 7: Unexpected symbol /
Warning: Missing period at end of file


Any ideas?

Thanks
 
First of all.
What COBOL compiler.

Second, post the full program, as just the code that you have will compile fine in all COBOL compilers I know of, though in some you may need to set up a "DLOAD" keyword.

and also post the full compile command.




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Sorry for not including enough info. I'm a bit of a novice at this. I'm trying to create a batch job to run from within a 3rd party system to invoke this shell script.

1. MicroFocus Cobol Compiler

2. Procedure Definition

000100******************************************************************
000200 050-EDIT-PARAMETERS SECTION 10.
000300******************************************************************
000400 050-START.
000500
000600 050-END.
000700
000800******************************************************************
000900 100-PROGRAM-CONTROL SECTION 10.
001000******************************************************************
001100 100-START.
001200
001300 MOVE 050 TO CRT-MSG-NBR.
001400 PERFORM 780-DISPLAY-MSG.
001500
001600 PERFORM 1000-DO-REPORT.
001700
001800 100-END.
001900
002000******************************************************************
002100 1000-DO-REPORT SECTION 50.
002200******************************************************************
002300 1000-START.
002400
002500 CALL "SYSTEM" USING WS-COMMAND.

003500 GO TO 1000-END.
003600
006200******************************************************************
006300 1000-END.
006400******************************************************************
006500

3. Working Storage

000100******************************************************************
000200* GLINTWS *
000300******************************************************************
000400 01 GLINTWS.

01 WS-COMMAND-LINE.
000500 03 WS-COMMAND-COM PIC X(21) VALUE "/test/glint/glint.sh ".

4. The program was generated via a 3rd party application that uses 4gl as a language. It has it's own compile commands so I'm not sure how much help it will be.
qcompile <data area> <system code> <program code>

5. Compile error log

Compiled on gfsapp12


scrgen -s TEST GL GLINT

Building /s0b0/test/apps/test/sdlib/GLINTSD
rptgen -t TEST GL GLINT
Processing /s0b0/test/apps/test/glsrc/GLINT.rpt
creating - /s0b0/test/apps/test/glsrc/GLINT.rd
Building COBOL Shell

Processing PgmInfo Request ...
bismark TEST GL GLINT
Syntax Check /s0b0/test/apps/test/glsrc/GLINTWS
( 7): Incomplete Quote, Error In TokRead
Syntax Error: Line 7: Unexpected Symbol /
Warning: Missing period at end of file
1 SyntaxErrors in /test/apps/test/glsrc/GLINTWS
Syntax Check /test/apps/test/glsrc/GLINTPD
Bismark Unable To Continue - Exiting
/test/env/bin/bismark: Error Encountered In Execution
/test/env/bin/lawbsh: Error Encountered In Execution



Thanks again
 
You may well have an &quot;Unexpected symbol /&quot; somewhere toward or beyond column 80. A typo.
 
Can the command not go beyond column 80? Is that what you're getting at?

The &quot;/test/glint/glint.sh &quot; is the fully qualified path to the shell script...no typos.

Could it be that a forward slash is not allowed?
Thanks
 
Some Cobol compilers will not accept statements past column 71. Try placing the Value clause on a seperate line and make sure it does not go past column 71.

etom
 
IF the code you post is really using up all the spaces mentioned than the variable is well past the 72 column.

As Etom mentioned place the VALUE clause on separate line and try it.

And when someone asks for the full program DO give us the full program, not just pieces of it.
If the program is to big then create a small program that issues the some error, but without any superflous code.

On this particular case, and because we are dealing with a precompiler, I would expect to see the content of
/s0b0/test/apps/test/glsrc/GLINTWS
as this is the &quot;file&quot; giving the error.
and also of
/test/apps/test/glsrc/GLINTPD
just to be sure.






Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Ok folks....I think I'm closer. Etom had the right idea. I shortened the Value clause and it got past the syntax error. Now I get something else. Here are the changes.

1. PD

000100******************************************************************
000200 050-EDIT-PARAMETERS SECTION 10.
000300******************************************************************
000400 050-START.
000500
000600 050-END.
000700
000800******************************************************************
000900 100-PROGRAM-CONTROL SECTION 10.
001000******************************************************************
001100 100-START.
001200
001300 MOVE 050 TO CRT-MSG-NBR.
001400 PERFORM 780-DISPLAY-MSG.
001500
001600 PERFORM 1000-DO-REPORT.
001700
001800 100-END.
001900
002000******************************************************************
002100 1000-DO-REPORT SECTION 50.
002200******************************************************************
002300 1000-START.
002400
002500 CALL &quot;SYSTEM&quot; USING WS-COMMAND.
PERFORM 700-PRINT-RPT-GRP.

003500 GO TO 1000-END.
003600
006200******************************************************************
006300 1000-END.
006400******************************************************************
006500


2. WS

000100******************************************************************
000200* GLINTWS *
000300******************************************************************
000400 01 GLINTWS.

01 WS-COMMAND-LINE.
000500 02 WS-COMMAND PIC X(25) VALUE &quot;/test/gl.sh &quot;.


3. Error

Compiled on gfsapp12


scrgen -s TEST GL GLINT

Building /s0b0/test/apps/test/sdlib/GLINTSD
rptgen -t TEST GL GLINT
Processing /s0b0/test/apps/test/glsrc/GLINT.rpt
creating - /s0b0/test/apps/test/glsrc/GLINT.rd
Building COBOL Shell

Processing PgmInfo Request ...
bismark TEST GL GLINT
Syntax Check /s0b0/test/apps/test/glsrc/GLINTWS
Syntax Check /s0b0/test/apps/test/glsrc/GLINTPD
Building Int From GLINTPD, GLINTWS, GLINTSD, GLINT.rd, wslibs & workfiles
Build Of Int Complete For GLINT
Editing PGM: GLINT
Building /s0b0/test/apps/test/glsrc/GLINT.cbl
Building /s0b0/test/apps/test/glsrc/GLINT.etb

Shell has been built.

Compiling /s0b0/test/apps/test/glsrc/GLINT.cbl with cob -vW e -C warning=1 -C noalter -C vsc2 /s0b0/test/apps/test/glsrc/GLINT.cbl -u
cob32 -C nolist -vW e -C warning=1 -C noalter -C vsc2 /s0b0/test/apps/test/glsrc/GLINT.cbl -u
* Micro Focus Server Express V2.0 revision 011 Compiler
* Copyright (C) 1984-2001 Micro Focus International Ltd. URN RXCAI/AA0/00000Q
* Accepted - verbose
* Accepted - nolist
* Accepted - warning(1)
* Accepted - noalter
* Accepted - vsc2
* Compiling /s0b0/test/apps/test/glsrc/GLINT.cbl
664 01 WS-COMMAND-LINE.
* 217-S** **
** Preceding item at this level has zero length
* Total Messages: 1
* Unrecoverable : 0 Severe : 1
* Errors : 0 Warnings: 0
* Informational : 0 Flags : 0
* Data: 55701 Code: 0
cob32: error(s) in compilation: /s0b0/test/apps/test/glsrc/GLINT.cbl
cob: Error Encountered In Execution
Errors encountered-c

Again, I really appreciate the handholding for this n00b [2thumbsup]
 
I dropped the 01 WS-COMMAND-LINE. line from the WS and it compiled.

Now if it will just work. LOL

Thanks for all the help folks.
 
This is way I asked for the full source.

You have two 01 levels together, so the COBOL compiler is saying that &quot;01 GLINTWS.&quot; is a ZERO size variable (which is not normally accepted).

Either remove this variable or change
000400 01 GLINTWS.

01 WS-COMMAND-LINE.
000500 02 WS-COMMAND PIC X(25) VALUE &quot;/test/gl.sh &quot;.

to be

000400 01 GLINTWS.

05 WS-COMMAND-LINE.
000500 10 WS-COMMAND PIC X(25) VALUE &quot;/test/gl.sh &quot;.




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Try to use the following, hope it will solve your problem.

WORKING-STORAGE SECTION.
01 WS-COMMAND-LINE.
03 WS-COMMAND-COM PIC X(25) VALUE &quot;/test/glint/glint.sh &quot;.
03 F PIC X(04) VALUE &quot; &quot; & X&quot;00&quot;.
PROCEDURE DIVISION.
CALL &quot;SYSTEM&quot; USING WS-COMMAND.


 
Try to use the following, hope it will solve your problem.

WORKING-STORAGE SECTION.
01 WS-COMMAND-LINE.
03 WS-COMMAND-COM PIC X(25) VALUE &quot;/test/glint/glint.sh &quot;.
03 F PIC X(04) VALUE &quot; &quot; & X&quot;00&quot;.
PROCEDURE DIVISION.
CALL &quot;SYSTEM&quot; USING WS-COMMAND-LINE.
 
Sounds like the compiler is hitting the &quot;/&quot; and baling out.

Ive had this promlem with other character strings.

Try the following

ASSUMING THAT YOUR USING ASCII &quot;/&quot; = HEX 2F

01 SYSTEM-COMMAND.
05 FILLER PIC X(01) VALUE X&quot;2F&quot;.
05 FILLER PIC X(01) VALUE &quot;test&quot;.
05 FILLER PIC X(01) VALUE X&quot;2F&quot;.
05 FILLER PIC X(01) VALUE glint.sh&quot;.

CALL &quot;SYSTEM&quot; USING SYSTEM-COMMAND.

OR YOUR COULD DEFINE THE SLASH IN WORKING STORAGE AND
STRING THE COMMAND TOGETHER.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top