I've created and deployed a Flask App with Apache2 server WSGI in which now would like to run a .sh script from the App. However, from calling from python code, it doesn't execute.
Here is the test.sh:
#!/bin/bash
echo "hi from shell script"
Here is my python flask app code index.py (runs when App is opened) but nothing is printed or executed:
import subprocess
subprocess.call('/var/www/FlaskApp/FlaskApp/scripts/test.sh')
To check that there is not errors in my code, I've check flask error logs, and no errors. Also, I created a script called test_shell_script.py with same python code as above (but not flask app code) and it runs great like this:
# test_shell_script.py
import subprocess
subprocess.call('/var/www/FlaskApp/FlaskApp/scripts/test.sh')
And then run it with python: python3 /var/www/FlaskApp/FlaskApp/test_shell_script.py
hi from shell script
I did change the permissions as well:
-rwxr-xr-x 1 root root 364 Nov 19 17:48 ../scripts/test.sh
What am I missing here which is not allowing my Flask app to run shell commands from the python code?