I have three php scripts. First, I start with an init script. The second is launched by the first, and the second uses shell_exec
to get the output from the third script, periodically passing it various parameters.
But this does not happen. When I var_dump
output of shell_exec
, in the second script I get NULL
. But when I print the actual command that is used in shell_exec
in the second script and try to enter it into the console, it works very well!
I tried the command from the console of the same user with which I run the init script.
This may be a resolution issue. But I have the correct permission settings i.e.
- + x for the third script
- the third script (virtually all three) belongs to the same user and group, I use the console with
Note. I tried to run the third script using shebang as well as remove shebang and add php
to the script path. Everything works fine with root.
Also, another note, the first script redirects the output of the second script to the log file (this is where I found the third script returning NULL
on shell_exec
)
UPDATE: code of the second script that uses shell_exec
$command = "/var/data/user-data.php '{$user}' '{$request['token']}' '{$request['secret']}'"; $data = json_decode( shell_exec( $command ), true );
I tried to print $command
as well as var_dump( shell_exec( $command ) )
. The former returns the expected (params), and the latter returns NULL
source share