× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I was able to recreate your situation on my end and I had the same
problems.

After digging around for a while I came across an example of using the
spawn api.

I think that api will solve your problems. It worked for me. I was able
to create a .txt file with the results of ls and I was able to return
HTML to the browser via STDOUT.

Here's a link to the link where I found an example by Scott Klement.
http://archive.midrange.com/midrange-l/200509/msg00287.html

Here are the changes I made to the original in order to make it work for
me.

parm(1) = '/QSYS.LIB/QP2SHELL.PGM' + x'00';
parm(2) = '/QopenSys/usr/bin/-sh' + x'00';
parm(3) = '-c' + x'00';
parm(4) = 'ls > /home/GRIZZLY/ls.txt' + x'00';

argv(1) = %addr(parm(1));
argv(2) = %addr(parm(2));
argv(3) = %addr(parm(3));
argv(4) = %addr(parm(4));
argv(5) = *NULL;

// ********************************************************
// Spawn the job
// ********************************************************

inh = *Allx'00';
pid = spawn( argv(1)
: 3
: fdmap
: inh
: argv
: envp
);

Hope that helps.

-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
On Behalf Of Aaron Bartell
Sent: Monday, November 26, 2007 11:04 AM
To: 'Web Enabling the AS400 / iSeries'
Subject: Re: [WEB400] QP2SHELL "taking over" standard output



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.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.