![No se puede iniciar el script bash con shell_exec](https://rvso.com/image/1415046/No%20se%20puede%20iniciar%20el%20script%20bash%20con%20shell_exec.png)
He estado buscando en Google e intentando resolver este problema con mi script php durante unos días y espero que alguien aquí pueda ver el problema que me falta para que mi script php inicie mi script bash.
Aquí está mi php:
//kickoff the yapeal script
echo "Starting yapeal.sh<br>";
echo "Current working directory: ";
echo getcwd() . "\n";
shell_exec('./yapeal.sh');
echo "<br>yapeal.sh ran, I hope.<br>";
Aquí está el yapeal.sh.
#!/bin/bash
cd /var/www/tools/applications
php -f /var/www/lib/yapeal/yapeal.php
sleep 5s
echo "`date -u` Yapeal kicked off, working" > bashoutput.log 2>&1
Aquí están los permisos en los archivos:
-rwxrwxrwx 1 www-data www-data 4640 Jul 10 07:20 index.php
-rwxrwxrwx 1 www-data www-data 2845 Jul 10 07:33 working.php
-rwxrwxrwx 1 www-data www-data 232 Jul 10 07:17 yapeal.sh
Esto es lo que obtengo como resultado en el navegador web:
Starting yapeal.sh
Current working directory: /var/www/tools/applications
yapeal.sh ran, I hope.
No hay resultados para el archivo bashoutput.log.
Revisé mi php.ini, no hay ninguna referencia a exec o shell_exec en la sección enable_functions.
Respuesta1
Resolví mi propio problema.
Modificó el código php a:
$output = shell_exec('./yapeal.sh');
echo $output;