× 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.



Alan,

Unix systems (which QShell attempts to emulate) do not do error handling the same way as IBM i. Unix programs work like this:

1) Every program has an "exit status", programmers can set this however they like, but by convention, an exit status of zero means "success", and anything else implies some sort of error.

2) Error messages are typically printed to the "stderr" (standard error) data stream that, by default, is printed on the screen.

3) There are a few exceptions that are detected by the OS rather than the program. These are uncommon, but are sent as "signals".

That is very different from the model used in native IBM i applications. In native programs, an exception is generated by sending a message, and that message gets logged to a program message queue. All of the program message queues in a job, put together, make up the "job log." Unix doesn't work that way.

The MONITOR opcode will not catch an error in a Unix program, because MONITOR is looking for exception messages -- it's designed for IBM i. And errors won't be in the job log because that's not how Unix programs work, Unix systems don't even have a job log.

Fortunately, IBM provides some environment variables to help adapt things when using a mixed environment (like yours) where native programs and Unix programs attempt to work together.

Unfortunately, I don't have time to explain more right now. But, please Google these, it should help you get started...

QIBM_QSH_CMD_ESCAPE_MSG
QIBM_QSH_CMD_OUTPUT

You also might consider using my UnixCmd tool instead of calling the QSH CL command.. IMHO, this is a more elegant way to use QShell from RPG.

http://www.scottklement.com/unixcmd/

Gotta run...
-SK



On 1/9/2016 12:21 PM, Alan Shore wrote:
Hi everyone
Before I forget, we are on V5r4

Here is my predicament
We are using QSH within RPGILE
For example

Monitor;
Pcmd = 'QSH CMD('+#Q+'cat ' +
%Trim(IfsPathNm) +
' | Rfile -wbQ -c ' +
#DQ + 'ovrprtf qsysprt ' +
' SAVE(*YES)' +
' OUTQ(' + %Trim(OutQNm) + ')' +
' splfname' +
'('+%Trim(OutQFileNm)+')' + #DQ +
' qsysprt' + #Q + ')';
PLength =%Len(%Trim(PCmd));
QCmdExc(PCmd:PLength);
On-Error;
OutErr = 'Yes';
EndMon;

Using debug, the contents of Pcmd is
QSH CMD('cat /Metapack/ZPL/Decoded/DMC3WT13S503L.BIN | Rfile -wbQ -c "ovrprtf qsysprt SAVE(*YES) OUTQ(IWPZEB10) splfname(C3WT13S503)" qsysprt')

What I am trying to do is move a label to an outq to be printed to a zebra label printer
Again, when in debug, the On-error is NOT touched - but the command does not work, when the profile running this program is *USER
But cutting and pasting this command to the command line as *PGMR, the command DOES work
So I am thinking there is some type of authorization problem - but why is it NOT being captured by the monitor end-mon
Is this the correct thing to use with Qsh?

A second piece of information
The program uses qsh commands elsewhere, in the same manner, and those commands are successful and show up in the users joblog
This one dosent


Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.