We have several instances where we use the CALL PGM(QP2SHELL) command in CL to call a php script. For example we might do:
CALL PGM(QP2SHELL) PARM('usr/local/zendsvr/bin/php-cli' '/scripts/myScript.php')
This would then run that php script located in /scripts.
Our problem is how to pass a parm to the php script. If I was doing this manually from qsh, i would just navigate to the /usr/local/zendsvr/bin directory and run "php-cli /scripts/myScript.php MyParm"
How can we do that calling it from CL? Would it just be:
CALL PGM(QP2SHELL) PARM('usr/local/zendsvr/bin/php-cli' '/scripts/myScript.php' 'MyParm')
Or is there a different syntax.
Calling php-cli from a CL program
-
- Posts: 187
- Joined: Wed Apr 22, 2009 2:29 pm
- Location: Edmonton, AB, Canada
Re: Calling php-cli from a CL program
Here is what I have to call from CL (using qsh instead of qp2shell):
So just about what you have but I don't have quotes around the parms for the script.
Scott
Code: Select all
CHGVAR VAR(&CMD) VALUE('. +
/usr/local/zendsvr6/bin/php-cli +
/www/zendsvr/htdocs/stand_alone/brmslogs.ph+
p ' *CAT &JOBNAM *TCAT '.' *TCAT &JOBUSR +
*TCAT '.' *TCAT &JOBNBR)
SBMJOB CMD(QSH CMD(&CMD)) JOB(BRMSLOGS) +
JOBQ(WEBJOBS) USER(SUPPORT) LOG(4 0)
Scott
Re: Calling php-cli from a CL program
I'm probably just missing it, but which part there is the parm that gets passed along to the php script?
-
- Posts: 187
- Joined: Wed Apr 22, 2009 2:29 pm
- Location: Edmonton, AB, Canada
Re: Calling php-cli from a CL program
Sorry, that would be the job info with periods in between, everything after the script name will be passed to the script in $argv
Scott
Code: Select all
*CAT &JOBNAM *TCAT '.' *TCAT &JOBUSR +
*TCAT '.' *TCAT &JOBNBR
Re: Calling php-cli from a CL program
I know this is an old post but thought that someone might be helped by it. This is an example of what we submit using php-cli with parameters:
CALL PGM(QP2SHELL) PARM('/usr/local/zendsvr6/bin/php-cli' '/your_path/your_script.php C2::HD_C2_DB::2::4::1::s')
Your script then pulls the values out: $Arg = explode ( "::", $argv [1] );
Hope that helps.
CALL PGM(QP2SHELL) PARM('/usr/local/zendsvr6/bin/php-cli' '/your_path/your_script.php C2::HD_C2_DB::2::4::1::s')
Your script then pulls the values out: $Arg = explode ( "::", $argv [1] );
Hope that helps.
Re: Calling php-cli from a CL program
Interesting idea. This way you don't have to null-terminate many separate parameters.
Re: Calling php-cli from a CL program
I'm able to pass a parameter into a php script via CL, using QP2SHELL, but what about php then returning a parameter back to the calling CL? Is that possible? I've tried everything I can think of.
Here is my call within my CL program -
CALL PGM(QP2SHELL) +
PARM('/usr/local/zendphp7/bin/php-cli' +
'/mypath/myphpscript.php' +
&PARAMTOPHP &PARAMFROMPHP)
Then in the PHP script I've set $argv[2] to a value to return back to the CL, but apparently it doesn't work that way.....?
Here is my call within my CL program -
CALL PGM(QP2SHELL) +
PARM('/usr/local/zendphp7/bin/php-cli' +
'/mypath/myphpscript.php' +
&PARAMTOPHP &PARAMFROMPHP)
Then in the PHP script I've set $argv[2] to a value to return back to the CL, but apparently it doesn't work that way.....?