Hopefully John M. because Charles M. is a little lost! I've never used popen().

If I had to add "UNIX services" to a COBOL program I think I would link 
(statically or dynamically) to a C program and do the UNIX stuff directly from 
there. But I have no idea if that would work well or what the gotcha's would be 
-- that would just be my first direction.

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Paul Gilmartin
Sent: Saturday, September 2, 2017 5:10 PM
To: [email protected]
Subject: Re: Unix-question

On Sat, 2 Sep 2017 21:24:35 +0000, scott Ford wrote:
>
>How can a LE enable application, using COBOL, C , etc. call UNIX 
>services, perform a function a UNIX function And retrieving output back 
>to COBOL..hence I would have to , have COBOL call C issue 'popen' build 
>pipe, send commands Etc..,  is this correct ?
> 
First, I'm COBOL-ignorant,

I believe (I'm not doing a lot of research) popen() is not a system call but a 
CRTL function.
You'd probably need a C bridge.

popen() returns a stream pointer (FILE *), not likely to be useful in COBOL.

The command is an argument to popen()  It may be a compound.

I might imagin in C:

    int filedes[ 2 ]

    pipe( filedes )
    popen( "cmd1; cmd2; ...; } >filedes[ 1 ] 2>&1", "r" );  /* omitting needed 
sprintf();  */

(Would it be easier to use spawn() rather than popen()?)

In COBOL (or C):
    call BPXWDYN( alloc dd(DDNAME) path( /dev/fd/filedes[ 0 ] ) filedata(TEXT) 
... " ) (or however you do a DYNALLOC in COBOL.)

Then OPEN and READ command output from DDNAME.

I suspect John M. (or Charles M.) might know far more, if you choose to impose 
on them.

-- gil

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

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

Reply via email to