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.