Posts: 4
Joined: Mon Sep 23, 2019 4:17 pm

Launching application from script

Mon Sep 23, 2019 5:40 pm

I cannot launch a python program from a script. Can anyone help?

Environment: RPI4, Apache2, php, SQL, WordPress
Application is a python3 program
Overall flow: html > php > sh > python program
.html script: calls php script via form action
.php script: calls shell script via exec (or shell_exec)
.sh script: launches python program

Problem: unable to launch python program, php script not launching shell script

- Test 1: launch shell script manually from terminal (sh script.sh) – OK (python program is launched)
- Test 2: launch html via file manager (file://...) – geany is loaded in a new window, showing php script. Clicking on “run” will complete the flow and launch the python program
- Test 3: launch html via browser (http://...) – nothing happens, flow stops on php script

I assume this is a permissions issue: the php script works from the terminal because it runs as privileged user, but if launched via the web browser it does not have the permissions to “execute”.

NB: all 3 scripts have the “x” flag (chmod +x).

I moved the 3 scripts and program from /home/pi/… to /var/www/html/… : still not working
I also tried to create new permissions in directory “sudoers.d” by creating a file with this line:
www-data ALL = (root) NOPASSWD
but that didn’t work either.
Any help would be appreciated.

Return to “General programming discussion”