I'm not sure what you are trying to do precisely.
Here's a complete example that works as expected:
-- "Hello stdout" goes to DD SYSPRINT
-- "Hello stderr" goes to DD SYSOUT
//EDCCB JOB (),WOLF,MSGCLASS=H,NOTIFY=&SYSUID
//PROCLIB JCLLIB ORDER='CBC.SCCNPRC'
//JOBLIB DD DSN=CEE.SCEERUN2,DISP=SHR *in case not in LNKLST*
// DD DSN=CEE.SCEERUN,DISP=SHR *in case not in LNKLST*
//*
//CC EXEC PROC=EDCCB
//COMPILE.SYSIN DD *
#include <stdio.h>
int main(int argc, char** argv) {
printf("Hello stdout\n");
fprintf(stderr, "Hello stderr\n");
return 0;
}
//BIND.SYSLMOD DD DSN=&&LOAD(HELLO),DISP=(NEW,PASS),
// SPACE=(CYL,(1,1,1))
//*
//GO EXEC PGM=HELLO
//STEPLIB DD DSN=&&LOAD,DISP=(OLD,DELETE)
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//
Now, IBM seems to some *some* forms of redirection (according to the C++ Prog
Guide) on the PARM= for executing C programs in batch. They really don't
document it completely, however.
Therefore, in order to have some fun with Gil, I tried this:
//GO EXEC PGM=HELLO,PARM='/ >DD:STDOUT 2>DD:STDERR'
//STEPLIB DD DSN=&&LOAD,DISP=(OLD,DELETE)
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//
which works :-)
My suggestion: build a HELLO program like this and test it under regular batch.
Then, try it it under an STC, and then under an STC running under MSTR. I
don't understand how that stuff works, but I would go one step at a time to see
where things work and don't work :-)
Kirk Wolf
Dovetailed Technologies
http://dovetail.com
On Fri, Jan 14, 2022, at 11:19 AM, Phil Smith III wrote:
> Kirk Wolf wrote:
>
> >This is nothing in LE or the C library that allocates DDNAME STDOUT
> automatically for the "stdout" standard stream. POSIX(ON) has no impact on
> this. So if you are running a C program directly with PGM= under MVS batch
> (without BPXBATCH), then it won't use DD:STDOUT.
>
>
>
> OK, that obviously fits my results.
>
>
>
> >For more information on use of standard streams with DDs, see "Ch 9. Using
> C and C++ standard streams and redirection" in the XLC/C++ Programming
> Guide. In there you will see that DD:SYSPRINT will be used if present, and
> otherwise dynamically allocated. You will see that there is also a silly way
> to redirect stdout on the PARM statement for a batch job.
>
>
>
> Reading that chapter, it talks about SYSPRINT, which I do have explicitly
> allocated:
>
> //SYSPRINT DD SYSOUT=O
>
>
>
> But while the SYSPRINT output is O, the rest is W (the default per the
> STCCLASS statement):
>
> JESMSGLG JES2 2 STCOPER W
>
> JESJCL JES2 3 STCOPER W
>
> JESYSMSG JES2 4 STCOPER W
>
> SYSPRINT Z830 102 STCOPER O
>
> SYS00001 Z830 108 STCOPER W
>
>
>
> Does this mean there's no way to do what we want? The:
>
> PARM='/ 2>&1'
>
> doesn't appear to be useful to me, since it still means stuff is in the
> stdxxx world.
>
>
>
> If the answer is "No" that's OK (with me, anyway) but I'm not clear that's
> what you said (yet)!
>
>
>
> Thanks again,
>
> ...phsiii
>
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
>
Kirk Wolf
Dovetailed Technologies
http://dovetail.com
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN