I need to run a script (text.sh) that needs sudo, without inputting password, for example:
sudo apt-get update >> /home/derp/test.txt
I have modified my sudoers file like this:
# This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL) ALL pedro ALL=(ALL) NOPASSWD: /home/pedro/Desktop/scripts/test.sh # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d
If I modify that script to become:
The output is:
real 0m0.000s user 0m0.000s sys 0m0.000s
as it should.
I really don't know what else to do...
The script is called because I get the password prompt in the console, so I don't think it is a Django or python problem..
------EDIT----- Apprently you need to specify the sudo in the python call, like this:
and you can leave it out of the script itself. So it is fixed.