1

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, $pipes, '/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!

hakre
200k55 gold badges454 silver badges868 bronze badges
asked Jan 25, 2010 at 4:35
4
  • What is the ouput of which php from the commandline? Commented Jan 25, 2010 at 4:39
  • 1
    I get the feeling this is safe-mode related. Is it enabled? Commented Jan 25, 2010 at 4:45
  • which php : /usr/bin/php Commented Jan 25, 2010 at 4:46
  • 2
    you're right zneak! i have to turn off safe-mode. Problem solved! thanks all Commented Jan 25, 2010 at 4:52

2 Answers 2

2

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"
answered Sep 12, 2011 at 20:30
Sign up to request clarification or add additional context in comments.

1 Comment

This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
1

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!');
}
answered Jan 25, 2010 at 4:39

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.