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
No one told what could cause this error, in case of migration from one host to another, remember about checking hostname in sudoers file:
So this is my /etc/sudoers config
User_Alias POWERUSER = user_name
Cmnd_Alias SKILL = /root/bin/sudo_auth_wrapper.sh
POWERUSER hostname=(root:root) NOPASSWD: SKILL
if it doesn't match
uname -a
Linux other_hostname 3.10.17 #1 SMP Wed Oct 23 16:28:33 CDT 2013 x86_64 Intel(R) Core(TM) i3-4130T CPU @ 2.90GHz GenuineIntel GNU/Linux
it will pop up this error:
no tty present and no askpass program specified
Make sure the command you're sudo
ing is part of your PATH
.
If you have a single (or multi, but not ALL) command sudoers
entry, you'll get the sudo: no tty present and no askpass program specified
when the command is not part of your path (and the full path is not specified).
You can fix it by either adding the command to your PATH
or invoking it with an absolute path, i.e.
sudo /usr/sbin/ipset
Instead of
sudo ipset
Other options, not based on NOPASSWD:
For Ubuntu 16.04 users
There is a file you have to read with:
cat /etc/sudoers.d/README
Placing a file with mode 0440 in /etc/sudoers.d/myuser with following content:
myuser ALL=(ALL) NOPASSWD: ALL
Should fix the issue.
Do not forget to:
chmod 0440 /etc/sudoers.d/myuser
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!
Try this one:
echo '' | sudo -S my_command