开发者

proc_open() path problem

开发者 https://www.devze.com 2022-12-18 11:36 出处:网络
i\'m using linux and php 5.2.12 i have problem with executing proc_open if i use proc_open(\'php script.php\', $descriptorspec, $pipes);

i'm using linux and php 5.2.12

i have problem with executing proc_open

if i use

proc_open('php script.php', $descriptorspec, $pipes);

it will show me error

sh: /php: No such file or directory

if i use

proc_open('/usr/bin/php script.php', $descriptorspec, $pipes);

or

proc_open('php script.php', $descriptorspec, $pip开发者_运维知识库es, '/usr/bin/');

it still show me same error.

i have no idea why it always append slash in front of command.

any help please?

thanks!


If you don't want to turn off safe-mode completely, just set this in your php.ini file

safe_mode_exec_dir = "/usr/bin"


Try doing:

$php = trim(shell_exec('type -P php'));

if (empty($php) !== true)
{
    proc_open($php . ' /path/to/your/script.php', $descriptorspec, $pipes);
}

else
{
    die('Install php-cli!');
}
0

精彩评论

暂无评论...
验证码 换一张
取 消