Thanks for the feedback Jim.
The winning combo for me looks like this:
python3 helloworld2.py > /tmp/stdout1.txt 2> /tmp/stderr1.txt
It lets you skip the 1> part and just use > for stdout.
Good to know for anyone else who wants to call qshell commands and pipe to stdout and stderr separately.
Regards,
Richard Schoen
Web:
http://www.richardschoen.net
Email: richard@xxxxxxxxxxxxxxxxx
Phn: (612) 315-1745
------------------------------
message: 2
date: Sat, 3 Aug 2019 22:09:17 -0400
from: "midrange" <franz9000@xxxxxxxxx>
subject: Re: [IBMiOSS] How to get Python errors to cause MSGW job
status?
Re: It doesn't appear there's a way to separate STDOUT from STDERR on QSH call from what I can tell.
(I'm not working in Python), but 2 thoughts:
Redirecting stdout and stderr in clp/clle One method
CHGVAR VAR(&ENVCO) VALUE('FILEAPPEND=' *TCAT &LOGF)
ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(&ENVCO)
REPLACE(*YES)
2nd, I would think the redirection of stdout and stderr would have to follow the rules of shell scripting (your executing a command in QSH).
That redirecting would be at the end of the command - I wouldn't know what shell scripting QSH follows.
Stdout descriptor is 1 stderr is 2 . > is a redirect . and although
just > will assume 1
But try this:
Redirect is after the command ... command 1>file1.txt 2>file2.txt or to get all in 1 file command file1.txt 2>&1
this call to QSH redirects the stdout to a native file
CHGVAR VAR(&LSCOMMAND) VALUE('LS -lT /bncf/ > +
/QSYS.LIB/' *TCAT 'BNCFIL' *TCAT +
'.LIB/listfile.FILE/listfile.MBR')
QSH CMD(&LSCOMMAND)
If this is not quite relevant - my apologies Jim Franz
As an Amazon Associate we earn from qualifying purchases.