View Full Version: Call "system" Not Returning To The Cobol P

LawsonTalk > Coding, Program Errors and Bugs > Call "system" Not Returning To The Cobol P



Title: Call "system" Not Returning To The Cobol P
Description: CALL "system" not returning command


wallaced - August 21, 2008 04:34 PM (GMT)
I am new to this forum, but like what I am seeing. I hope you folks
can collectively lend a hand.

I am running a shell script to launch a perl script and then create a
log file I can read from the program. The shell script runs, the perl scrip
runs, the log is created and then everthing stops. Control never returns to
the COBOL program. I run lots of scripts using the same basic format and
have never had this problem. Any ideas?

The script is created as a print file.
********************************

#!/bin/ksh

set -x

## Purpose: Run a PERL Script and
## capture output.
## Date Written: 08/14/2008

export Log=/lawson/apps/prod/work/ArchivePerl.log
echo "starting PERL script" >> $Log
date >> $Log
cd /lawson/gen/bin/
perl zzarch_import.pl ar
export ErrLvl=$?
if [[ $ErrLvl != 0 ]]
then echo "Error Level = $ErrLvl" >> $Log
date >> $Log
echo "Not Complete" >> $Log
echo "---------- Non-Zero Abend : ERROR ----------------" >> $Log
echo "Script Exiting" >> $Log
exit $ErrLvl
else
date >> $Log
echo "Perl script complete" >> $Log
exit
fi

**********************************

The command to execute the script is created:

INITIALIZE WS-COMMAND-STRING.
STRING "ksh " DELIMITED BY SIZE
ICLAWDWS-LAWDIR DELIMITED BY SPACES
"/print/" DELIMITED BY SIZE
CRT-USER-NAME DELIMITED BY SPACES
"/" DELIMITED BY SIZE
WS-FORMAT-OUT DELIMITED BY SPACES
"/1/ararcprl" DELIMITED BY SIZE
INTO WS-COMMAND-STRING.
CALL "system" USING WS-COMMAND GIVING WS-RETURN-COMMAND.

WS-FORMAT-OUT is the CRT-JOB-NAME in lower case. It runs great,
it just never returns.

Thanks

trezaei - August 21, 2008 05:43 PM (GMT)
So how are you sure that control never returns?
Try putting a DISPLAY statement after the system call.

Also, it may be necessary to have a return statement in your secripts.

Is your Perl script returning conrtol back to your shell?


wallaced - August 21, 2008 06:07 PM (GMT)
Hi,

The perl script is returning control to the shell script. The output log is completed and the script exit is echoed in the lawson log. At this point the log just sits with an
----------------------------end------------------------------------------------

The program never goes to the next line of code after the system call.

Dan

wallaced - August 21, 2008 06:54 PM (GMT)
More information

here is the pertenant job log from a new run

* PHASE 2 Ended: 14:17:37
*****************************************
**********************************
* PHASE 3 - ARCHIVE AR SYSTEM *
**********************************

## Shell script starts

* Started: 14:17:37
+ export Log=/lawson/apps/prod/work/ArchivePerl.log
+ echo starting PERL script
+ 1>> /lawson/apps/prod/work/ArchivePerl.log
+ date
+ 1>> /lawson/apps/prod/work/ArchivePerl.log
+ cd /lawson/gen/bin/
+ perl zzarch_import.pl ar
Thu Aug 21 14:17:55 EDT 2008

## perl script starts

Loading ARADJUST ... 93 records processed.
Loading from /lawson/archive/ADJ.00

File Processed Added Duplicate Bad
---- --------- ----- --------- ---
ARADJUST 93 0 93 0

File Processed Added Duplicate Bad
---- --------- ----- --------- ---
ARRTM 1 0 1 0
Loading from /lawson/archive/ARJ.00
Loading from /lawson/archive/BLH.00
Loading from /lawson/archive/FTT.00
Loading from /lawson/archive/RVH.00
Loading from /lawson/archive/RVD.00

Thu Aug 21 14:44:37 EDT 2008
+ export ErrLvl=0
+ [[ 0 != 0 ]]
+ date
+ 1>> /lawson/apps/prod/work/ArchivePerl.log
+ echo Perl script complete
+ 1>> /lawson/apps/prod/work/ArchivePerl.log
+ exit
======================================End=======================================
Help Find FndNxt Show Send Home
Bottom


The "loading" statements are from the perl script. the "+" lines are the echo from the shell script. The last line of the shell is exit. The program is not responding and has to be killed from the command line.

Dan

MannieJ - August 21, 2008 09:37 PM (GMT)
as Trezaei said you need to put a display after the call in your cobol program just to see if it returns from the call routine. You may also need to post the WS of your WS-COMMAND-STRING.

Usually here's what I do in unix:
1. Create a ksh script (Sample.ksh) in a common bin directory. Something like
GENDIR/bin.

2. In your cobol program you string the name of the ksh script
STRING "Sample.ksh parm1 parm2 parm3" DELIMITED BY SIZE
INTO WS-COMMAND-STRING.
CALL "SYSTEM" USING WS-COMMAND-STRING.

Works everytime.


trezaei - August 22, 2008 12:26 AM (GMT)
Post the part of your code and the few lines around it that do the system call.
And put it in CODE tag so it looks like this:


CODE
When you put stuff in code tags it looks like this so we can read it easier :D

wallaced - August 22, 2008 03:33 PM (GMT)
Here is the section that creates the script and executes it.

CODE
*****************************************************************
2500-ARCHIVE-AR            SECTION.
*****************************************************************
2500-START.

    OPEN OUTPUT ARARCPRL-FILE.

    MOVE "/lawson/gen/bin/"         TO G8-FILE-PATH.
    MOVE "zzarch_import.pl ar"      TO G8-SCRIPT-SYSTEM.

    MOVE GN8-SND-SCRIPT         TO RPT-GROUP-REQUEST.
    PERFORM 700-PRINT-RPT-GRP.

    CLOSE ARARCPRL-FILE.

    PERFORM 2510-LAUNCH-SCRIPT
    THRU    2510-END.

    PERFORM 2520-READ-ARCHIVE-LOG
    THRU    2520-END.

    GO TO 2500-END.

*****************************************************************
2510-LAUNCH-SCRIPT.
*****************************************************************

    PERFORM 1000-CREATE-LAWDIR-FILENAME-61.

    MOVE CRT-JOB-NAME           TO WS-FORMAT-IN.

** Replace uppercase letters in JOB-NAME with lowercase.

    PERFORM 2590-LOWER-CASE
    THRU    2590-END
        VARYING WS-NN  FROM 1 BY 1
        UNTIL  (WS-NN > 10).

** Launch the script. It will be run right from the print
** directory.

    INITIALIZE WS-COMMAND-STRING.
    STRING "ksh "               DELIMITED BY SIZE
           ICLAWDWS-LAWDIR      DELIMITED BY SPACES
           "/print/"            DELIMITED BY SIZE
           CRT-USER-NAME        DELIMITED BY SPACES
           "/"                  DELIMITED BY SIZE
           WS-FORMAT-OUT        DELIMITED BY SPACES
           "/1/ararcprl"        DELIMITED BY SIZE
           INTO WS-COMMAND-STRING.

    DISPLAY WS-COMMAND-STRING.

    CALL "system" USING WS-COMMAND GIVING WS-RETURN-COMMAND.

    DISPLAY "IM BACK".

2510-END.


The first display produces the following text:
QUOTE
ksh /lawson/apps/print/dwallace/ararcdvw-1/1/ararcprl


The script executes perfectly, but the program never gets to the second display.

Dan

wallaced - August 22, 2008 04:34 PM (GMT)
My apologies to all of you. By adding the display after the call I found that the script was returning and the problem was programatical at a point after the script completed. I do thank you for the help in finding what to look for.

Thanks,

Dan

trezaei - August 22, 2008 05:14 PM (GMT)
QUOTE (wallaced @ Aug 22 2008, 08:34 AM)
My apologies to all of you. By adding the display after the call I found that the script was returning and the problem was programatical at a point after the script completed. I do thank you for the help in finding what to look for.

Thanks,

Dan

Awesome! Glad we could help :D




Hosted for free by InvisionFree