Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have to execute a shell script as another user, but without be prompted for password.

I've edited the etc/sudoers file with visudo, adding the following line.

_www  localhost=(otheruser) NOPASSWD:/patho/to/my/script.sh

If I understand how sudo works, this means that user _www is allowed to execute like user 'otheruser', without be prompted for password, only from localhost.

is that correct?

the system continue to prompt for the password...

share|improve this question

migrated from stackoverflow.com Jan 11 at 0:31

This question came from our site for professional and enthusiast programmers.

    
No, it means that the _www user can do /patho/to/my/script.sh, which is not enough. You should add /bin/sh to make it an executable command. All together, /bin/sh /patho/to/my/script.sh. –  fedorqui Jan 10 at 14:22
    
Thank you, but it still prompt me for the password –  user3181041 Jan 10 at 14:25
    
This question is off-topic here. If the question was about the script file itself, it would be appropriate, but you're asking about system configuration instead. Your question would be more suitable for Ask Ubuntu or Super User instead. –  Ken White Jan 10 at 14:34
    
Ok, I will ask to the right place. Thank you. –  user3181041 Jan 10 at 16:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.