1

Here's the thing,

$file="myjpg.jpg";
$runme="/var/www/html/facedetect/facedetect ".$file;
$output=shell_exec($runme);
var_dump($output);

Turns

NULL

But in reality the exact same command run through ssh takes a little while to complete, about 15 seconds and it does return an output.

So I'm thinking that PHP isn't waiting and exits before that completes.

What can be done to fix this? any special setting in the ini, something.

Or is there a miss configuration somewhere that might be related for shell_exec not to send myjpg.jpg as the argument for the executable. I'm just clueless about this.

1
  • The output from the executed command or NULL if an error occurred. so there is an error. Commented Mar 6, 2013 at 19:03

1 Answer 1

2

shell_exec() returns NULL when the command fails; i.e. when it returns a none-zero exit value.

This is most probably the case.

To debug, try exec(), which always returns a value, it will return the error.

My gut-feeling is that /var/www/html/facedetect/facedetect or $file; are not accessible by the user that runs PHP (probably www-data).

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, I think it might be that, how could I execute with shell_exec as root for example ? I tried exec and yes, error is 127 - in theory assumed to be wrong path but your theory sounds probably like the solution, it's related to that, the user that runs php might not be root, how could I configure so php is runt by root or if that ain't a good idea, where should I be headed if you could please tell me
user is apache, but yeah the contents of the executable itself are linked to many other files which I wonder would also require authority for the user apache, and there's the problem. I'm really loving linux more every day with its hundreds of locks and hours to unlock each, it's just awesome.

Your Answer

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.