shell_exec fails if run from Iseries Job Scheduler

General discussion on Zend Server for IBM System i
Post Reply
Posts: 34
Joined: Mon Feb 13, 2012 5:17 pm

shell_exec fails if run from Iseries Job Scheduler

Post by deathcomp » Wed Oct 19, 2016 2:40 pm

So I have a simple php file that just does an ls -l and outputs the results to a file.

Code: Select all

$STDOUT = fopen('/scripts/test.log', 'a+');
echo "\n";

$result = shell_exec("ls -l");
echo $result;
I have a CL program that calls this script:

Code: Select all

 CALL  PGM(QP2SHELL) +                          
       PARM('/usr/local/zendsvr6/bin/php-cli' + 
I can run this program file myself interactively if I do a "Call PGM(PHPTEST05)". That works just fine and it outputs the result of ls -l to that test.log file.

The problem comes when I set up an entry in the job scheduler going to wrkjobscde. I create an entry that does the same call pgm(phptest05) and every time I get this php error:

PHP Warning: shell_exec(): Unable to execute 'ls -l' in /scripts/tab/test.php

We did a migration to a new iseries and new version of zend server. We were on version 5.6.0 on the old iseries and our new iseries is running zend server 8.5.5.

The scheduled job runs as the same user that I'm logged in with so I can't see it as a permission problem. Also we have a dozen scheduled jobs that do different shell_exec commands and every one is failing like this. I just created this test script to work on the problem.

So any ideas as to why the program runs file and the shell_exec works if I run the pgm interactively, but fails if submitted by the job scheduler?

Post Reply