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



Scott,

Thanks for working on this. As potentially ugly as it is, in a way, it is
cleaner. I have a really stripped down CL, only purpose is to turn around and
use SNDPGMMSG command. Kind of like taking the scenic route. Having written
that, sometimes things in the QSH side can be a little obtuse, all by
themselves. Running a CL program from QSH just to SNDPGMMSG is ugly in one
way, but is potentially clearer to somebody unfamiliar with QSH. This little
project is potentially a maintenance headache duw to the hybrid nature mixing
CL, RPG IV, and QSH. In this case, sure would have been nice if this system
could invoke sFTP without being in QSH. QSH is very powerful. And it is a
shame the rest apparently isn't.

This email, like the articles you have posted are DEFINITELY in my KEEP file. Way too valuable to loose.

Thanks again for your efforts!

John McKee

Quoting Scott Klement <midrange-l@xxxxxxxxxxxxxxxx>:

John,

Again, the CL program SHOULD work... try debugging that a little
more... otherwise, the QMHSNDM API should also work.

Just in case it's useful... here's a function to place in a QShell
script that uses QMHSNDM:

function log_sysopr() {
doubledquotes="${1//'/''}"
cmd=$(printf "CALL QMHSNDM (CPF9897 'QCPFMSG *LIBL' '%s' \
x'%08x' *INFO *SYSOPR x'00000001' ' ' x'00000000' \
x'00000000')" "$doubledquotes" ${#doubledquotes})
system "$cmd"
}

The API call is a bit ugly, IMHO, that's why I wrapped it up in a
function. As you can see, this function also doubles-up any apostrophes
you pass to it, to escape those properly...

To log something, you'd do this:

log_sysopr "John's message for QSYSOPR"

Alternately, if you want to do this from CL there will be a bit of a
challenge dealing with the length of a string, since CL expects the
length of the parameter to be known at compile-time (which is an alien
concept in QShell). But QShell does add a null (x'00') character to
the end of the parameter, so a loop can be used to work around the issue.

PGM PARM(&MSG)

DCL VAR(&MSG) TYPE(*CHAR) LEN(80)
DCL VAR(&LEN) TYPE(*INT) LEN(4)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X'00')

CHGVAR VAR(&LEN) VALUE(1)
DOWHILE (&LEN *LE 80 *AND %SST(&MSG &LEN 1) *NE &NULL)
CHGVAR VAR(&LEN) VALUE(&LEN + 1)
ENDDO
CHGVAR VAR(&LEN) VALUE(&LEN - 1)

SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) +
MSGDTA(%SST(&MSG 1 &LEN)) +
TOMSGQ(*SYSOPR)
ENDPGM

See what I mean? I have to use the DOWHILE loop to find the x'00'.
Otherwise, I'd run the risk of getting "garbage" at the end of the
string. And if QShell didn't pass at least 80 chars (in this example)
changing the contents of &MSG would corrupt memory.... so I can't just
"strip off the garbage" -- not safely, at any rate. Thus the loop,
above... it should solve that problem.

Then you call it from QSH like this:

/qsys.lib/mylib.lib/logqsysopr.pgm "This is a test message"

I have to admit, I like the API example better than the CL example...
Neither example is as pretty as I'd like it to be, but I think the API
call is slightly less ugly than the CL program approach.

I know you've already figured it out on your end, so this may be
academic at this point... but I had a minute, so I thought I'd try the
options.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.






As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.