bash - php shell_exec and exec doesn't work with shell script -


so code raspberry pi still shot raspicam , save on directory,

<?php   exec('raspistill -n -hf -o /var/www/img/image.jpg --timeout 1'); ?> 

i have given ownership , permission read/write in forlder using -r. ls -al in /var/www this

drwxr-xr-x  3 www-data www-data 4096 jun 19 08:05 . drwxr-xr-x 12 root     root     4096 jun 19 05:54 .. -rwxrwxrwx  1 www-data www-data   74 jun 19 08:30 getimg drwxrwxrwx  2 www-data www-data 4096 jun 19 09:21 img -rw-r--r--  1 root     root       70 jun 19 10:07 index.php 

getimg script tried run script file shell_exec('/bin/bash ./getimg'); doesn't work.

i have added /bash/bin , tried run script without using script file doesn't results.

how ever when try run php file in terminal, creates image should. figure must permission issue, else should permissions? have given rights directory.

edit

so have found workaround this. since don't know cause problem, i'd not mark answer, please vote appear @ top.

i execute script using cgi scripts. have created shell script in /usr/lib/cgi-bin/

#!/bin/bash echo "content-type:text/html\n" sudo raspistill -vf -n -o /var/www/img/image.jpg --timeout 1200 --metering matrix echo "status: 204" 

i saved capture , made executable, did nothing permissions though.

sudo chmod +x capture 

now when open link http://192.168.1.85/cgi-bin/capture browser still me 500 internal server error message. how ever, image still created.

i need 500 internal server error fixed.

[i'd add comment don't have enough points it]

  • if use optional parameters $output , $return_var capture output , return value get?

    string exec ( string $command [, array &$output [, int &$return_var ]] )

  • does command rely on environment variables may available when run user not www-data? (you can use env command check that)

  • does still work if run via terminal after switching user www-data?


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -