Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I need to run a script ( 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/
# 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:['sudo', "/your/"]) 

and you can leave it out of the script itself. So it is fixed.

share|improve this question

closed as too localized by qbi, Seth, Mik, Eric Carvalho, hhlp Feb 25 '13 at 10:50

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Welcome to Ask Ubuntu! Since you found the solution, you should post this as your own answer to your question. Then, two days later, you can even mark this as the accepted answer. This will help others to see that your problem is solved (so we know you don't need help), and even more importantly, this will help other people who may search for help with the same problem. – Eliah Kagan Jun 22 '12 at 11:39

Browse other questions tagged or ask your own question.