I am trying to compile some sources using a makefile. In the makefile there is a bunch of commands that need to be ran as sudo
.
When I compile the sour
I was able to get this done but please make sure to follow the steps properly. This is for the anyone who is getting import errors.
Step1: Check if files and folders have got execute permission issue. Linux user use:
chmod 777 filename
Step2: Check which user has the permission to execute it.
Step3: open terminal type this command.
sudo visudo
add this lines to the code below
www-data ALL=(ALL) NOPASSWD:ALL
nobody ALL=(ALL) NOPASSWD:/ALL
this is to grant permission to execute the script and allow it to use all the libraries. The user generally is 'nobody' or 'www-data'.
now edit your code as
echo shell_exec('sudo -u the_user_of_the_file python your_file_name.py 2>&1');
go to terminal to check if the process is running type this there...
ps aux | grep python
this will output all the process running in python.
Add Ons: use the below code to check the users in your system
cut -d: -f1 /etc/passwd
Thank You!