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



Hello Bernd,

I now got to know, how one can run a PHP script on the i5 from a RPG
program.

It really depends on what you mean by "run a PHP script". The PHP language was really designed to be run from a web server and the code is designed to be embedded inside a web page. So you wouldn't typically run a PHP script from an RPG program, you'd run it by pointing a web browser at a particular URL, and that woould cause the web server to run the PHP script.

If you wanted to open a browser from an RPG program, you could do so via the STRPCCMD CL command (which can be run via QCMDEXC), this could open up a browser on your desktop which could, in turn, run the PHP script.

Or if you wanted to invoke the PHP program directly, and have the output go to your RPG program instead of to a browser (which would basically be the user's screen) you could invoke it through the web server using a tool like HTTPAPI or GETURI, or you could roll your own by calling the socket API.

If you're using PHP in a non-traditional manner. (i.e. you're NOT using it for web development, but are using it as a regular script -- much the same way you'd use QShell or REXX) it's certainly possible to run the script directly.

Most PHP implementations run under PASE, so you'd use the QP2SHELL API to launch the php command interpreter, and you'd pass the '-f' switch to tell PHP to run a script from a file, and then you'd pass the name of the script. For example, if you're using Zend Core as your PHP interpreter, you'd code this (it's CL, but you could do the same thing in RPG via either a prototype or CALL/PARM):

CALL PGM(QP2SHELL) PARM('/usr/local/Zend/Core/bin/php' +
'-f' '/path/to/myscript.php')

If you need your RPG program to control the input and output from the script, you can do that by creating pipes for stdin, stdout and stderr in your program, and running the QP2SHELL API via the spawn() API. That way, your data is piped to the API, and it's output is piped back to you.

That's a basic overview without going into specifics, since I don't know what exactly you wanted to know. If you want more detail on any of the methods, please reply and tell me what you're looking for.

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.