On Sat, 17 Mar 2018 19:22:37 +0000, scott Ford wrote:

>I am trying to understand how to issue a unix via a Cobol Program running
>in Batch ..I found an example  IBM supplied...
> 
Why would someone use Batch COBOL to run a shell to use TSOCMD to execute
a TSO command?  Rube Goldberg?

>      Working-storage section.
>       01 Start-Filler      pic x(41)
>            value '********** Working Storage Begin ********'.
>       01 exec-path         pic x(100).
>       01 exec-path-ptr     pointer.
>       01 exec-parm1        pic x(100).
>       01 exec-parm1-ptr    pointer.
>       01 exec-parm2        pic x(100).
>       01 exec-parm2-ptr    pointer.
>       01 null-ptr          pointer value null.
>       Local-storage section.
>       01 rc                pic s9(9) binary.
>       Procedure division.
>           Move Z'tsocmd' to exec-path.
>           Move Z'SEARCH CLASS(USER)' to exec-parm1
>           Set exec-path-ptr to address of exec-path
>           Set exec-parm1-ptr to address of exec-parm1
>           Set exec-parm2-ptr to address of exec-parm2
>                      Call 'execl' using by value exec-path-ptr
>                              by value exec-parm1-ptr
>                              by value null-ptr
>                        returning rc
>           if rc = 0 then
>              display 'tsocmd worked'
>           end-if
>           Goback.
>
>My problem is how to i route the output back the caller ? I thought if I
>used STDOUT it would , but apparently not.
>
>//ETESTR4  JOB SYSTEMS,MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,PRTY=8,
>//     NOTIFY=&SYSUID,REGION=4096K
>//STEP1  EXEC  PGM=CBLUNIX,REGION=0K,
>//   PARM='POSIX(ON) ALL31(ON) ENVAR("_CEE_ENVFILE=DD:STDENV")/'
>//STEPLIB  DD  DSN=IDF.TESTUNIX.LOADLIB,DISP=SHR
>//SYSPRINT DD  SYSOUT=*
>//SYSOUT   DD  SYSOUT=*
>//STDENV   DD  SYSOUT=*
>/*
As someone has already pointed out, STDENV should be SYSIN, not SYSOUT.

I believe STDIN, STDOUT, STERR, and STDENV DDs are peculiar to
BPXBATCH.  but you could invoke BXBATCH as if it were a standard
batch program

UNIX programs generally expect stdin, stdout, and stderr to be available.
Otherwise they misbehaive badly.

I'd be inclined to BPX1OPN /dev/null.  BPX1PIP to create a pipe.  Invoke the
UNIX program with BPX1SPN, assigning the null descriptor to descriptor 0
and the input end of the pipe to both descriptors 1 and 2.  DYNALLOC (BPXWDYN?)
the output of the pipe to a DDNAME and read the program's output from that.

I've done similar with Rexx, never with COBOL.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to