The main caveat to your approach is that it assumes the RPG programmer has all the knowledge

Often a non-IBMi developer gets involved and using curl and other open-source code makes better sense.

Also your approach to QSH only gives you a return code. It doesn't give you the context that often lives in the stdout/stderr logging, unless I am wrong.

That's why QSHEXEC/QSHBASH were written as a very thin veneer over the QSH command but with all the added benefits of stdout/stderr capture however you want it.

We all have our preferences for sure.

Regards,
Richard Schoen
Web: http://www.richardschoen.net
Email: richard@xxxxxxxxxxxxxxxxx
------------------------------

message: 3
date: Wed, 9 Apr 2025 16:26:34 +0000 (UTC)
from: cesco via RPG400-L <rpg400-l@xxxxxxxxxxxxxxxxxx>
subject: Re: Calling Curl from RPG or CL


I am new to CURL.
one calls curl from RPGLE or CLLE.

Generically and personally (CURL beside) to invoke a PASE binary without external dependencies (living off the land...) I just use STRQSH to the binary or a shell .sh script that wraps the binary.
like i,e, STRQSH CMD('/QOpenSys/pkgs/bin/php /scripts/sftpupload_ifsdir.php')

I tend to avoid to string concatenations and stuff in CL, a lot of time is lost debugging this kind of things that should be trivial and simple, so to pass parameters down from ILE to the PASE I usually use environmental variables (benefits of having basically a named dictionary, each variable a name) and any unix language can then access them.
This I found is pretty robust in time.

To get the a value back from the called PASE in ILE, to work out an internal protocol, the only approach I've found is use the return value of the PASE monitoring for escape messages setting QIBM_QSH_CMD_ESCAPE_MSG

------------------------------

message: 4
date: Wed, 9 Apr 2025 16:28:51 +0000 (UTC)
from: cesco via RPG400-L <rpg400-l@xxxxxxxxxxxxxxxxxx>
subject: Re: Calling Curl from RPG or CL

In any case if the scope of the problem is web services calling in a robust way, I would suggest just go HTTPAPI or the stock DB2 functions already on the system.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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

This mailing list archive is Copyright 1997-2025 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.