Another thing to check is if the environment variable
QIBM_USE_DESCRIPTOR_STDIO is set to 'Y'.
Here is a copy/paste of me starting up QShell and typing 'set'<enter>:
QIBM_CCSID=0
QIBM_DESCRIPTOR_STDERR=CRLN=N
QIBM_DESCRIPTOR_STDIN=CRLN=Y
QIBM_DESCRIPTOR_STDOUT=CRLN=N
QIBM_MULTI_THREADED=N
QIBM_USE_DESCRIPTOR_STDIO=I
QSH_REDIRECTION_TEXTDATA=Y
Looks like value is set to 'I'. Note that this was from an interactive
session; does the value change while in a batch CGI job? I am not even sure
how I would check this.
I did a 'set' command from my CGI program and it produced the following, so
it appears to be set correctly when in the CGI bach job:
QIBM_USE_DESCRIPTOR_STDIO=Y
Is your shell redirecting its output?
Here is the pertinent code. Note that this is using QP2SHELL2 vs. QP2SHELL
- I have tried both without success.
D QP2SHELL2 PR extpgm('QP2SHELL2')
D command 32767A const options(*varsize)
D parm1 32767A const options(*varsize:*nopass)
D parm2 32767A const options(*varsize:*nopass)
...
cmd =
'ls > /home/aaron/ls.txt' + x'00';
QP2SHELL2('/QOpenSys/usr/bin/-sh' + x'00'
: '-c' + x'00'
: cmd );
stdout('Content-Type: text/plain' + x'0D250D25');
stdout('
https://www.company.com/someurl');
*inlr = *on;
I changed the above code and put the Content-type line _before_ the
execution of QPSHELL2 and put a simple 'ls' as the command (without any
redirects). That caused a listing of programs in the current library to be
sent back to the client (i.e. returned from Apache). Not sure what this
gives me other than knowing that the same standard output is being used from
QShell.
I tried changing the program to use the OVRDBF code you included, but it
produced the same results (i.e. the standard output wasn't being sent to
Apache after QP2SHELL2 executed).
Thanks for your response. Does what I've added in this email give you any
more ideas?
Aaron Bartell
http://mowyourlawn.com
-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On
Behalf Of Grizzly Malchow
Sent: Monday, November 26, 2007 9:36 AM
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] QP2SHELL "taking over" standard output
Aaron,
Is your shell redirecting its output?
I thought I read that a new STDIN, STDOUT, and STDERR get created for
each shell that does a redirect and that STDOUT needs to be redirected
prior to running QSHELL.
Something like:
CRTPF (QTEMP/STDOUT)
OVRDBF(STDOUT) TOFILE(QTEMP/STDOUT)
QP2SHELL(SomeShell)
DLTOVR (STDOUT)
Then you return your html to the browser.
I was thinking that if the shell is redirecting output to a file or
print that it might not be releasing STDOUT when it is finished. If the
shell does redirect output I would guess that the html that is supposed
to go to the browser is being written to the same place your shell
directs its output.
Another thing to check is if the environment variable
QIBM_USE_DESCRIPTOR_STDIO is set to 'Y'. I would imagine it already is,
but might be worth looking into.
As an Amazon Associate we earn from qualifying purchases.