sudo in a shell script

Johann Spies jspies at sun.ac.za
Fri Jul 15 10:26:14 UTC 2005


On Fri, Jul 15, 2005 at 02:20:21PM +0430, Behrang Saeedzadeh wrote:
> I want to write a shell script like this:
> 
> 	sudo rmmod ipw2200
> 	sudo modprobe ipw2200
...
> Are there any options available for sudo for
> passing the password directly to it instead
> of waiting for the prompt?


One way of doing it is to enable a passwordless sudo for the user that
runs the script for that spesific command.  I use this technique to
allow nagios to use some commands on my servers.  In /etc/sudoers I
use this:

nagios ALL = NOPASSWD: /usr/local/bin/telq, /bin/df

Regards
Johann
-- 
Johann Spies          Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch

     "I have been young, and now am old; yet I have not seen
      the righteous forsaken, nor his children begging
      bread."  
                                  Psalms 37:25 




More information about the ubuntu-users mailing list