0

I can't see why exec() doesn't run on RaspberryPi but it outputs 'something'. Can someone please help me?

<?php
echo exec('GPIO.Output 1 1');  
echo('something');  
?>
1
  • 1
    How do you know it doesn't work? Is GPIO.Output an actual executable? Does it work from the command line? Does the PHP user have permission to run it? Does the webserver user have permission to access the files in /proc/ that GPIO manipulating programs need to write to? Commented May 10, 2016 at 13:02

3 Answers 3

1

Remove exec from the disabled functions in your php.ini file

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

Comments

0

exec() returns only last line of executed command's output. Use shell_exec() instead.

Alternatively you can make use of seconde exec() argument which like:

$output = array();
exec('GPIO.Output 1 1', $output);  // $output is passed by reference

Now $output contains command's output with every line as a separate array element

Comments

0

Thank you all for your help. I used the system() function insted, and it worked. Here is the code:

`

$last_line = system('/var/www/pornire_bec.cgi', $retval);

echo ' Last Line: ' . $last_line . ' Return Value: ' . $retval; ?>`

Comments

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.