Using sudo in scripts
gcall at starcalif.com
Wed Aug 7 16:38:19 EDT 2002
Okay, maybe I'm an idiot and not doing something correctly, because it
doesn't seem to work for me :)
Here is a sample menu script (just for testing)...
echo "---------- TEST Menu ----------"
echo "1. Run \"ls\""
echo "2. Run \"ps\""
echo "3. Run \"mount\""
echo "Choice: " ; read choice
case $choice in
Here is a sample of my sudoers file:
I execute sudo /home/gcall/test.mnu as user "gcall". Once in this menu,
all 3 commands will run without going through sudo. I *thought* that I
would be denied ls and ps, but permitted to run mount.
If I prefix all of the commands with sudo in the script, it then works.
Am I doing something wrong, or am I assuming incorrectly that all
commands in this script would be prefixed with sudo automatically?
I was hoping to wrap EVERYTHING in the script to use sudo, if I invoked
the script using sudo ---- make sense??
Thanks for all your input!
On Wed, 2002-08-07 at 11:01, Brent Fortman wrote:
> No, you do not have to pre-fix every command with sudo. Sudo <myscript>
> will execute all commands in <myscript> as root.
> -----Original Message-----
> From: Gary Call [mailto:gcall at starcalif.com]
> Sent: Wednesday, August 07, 2002 11:38 AM
> To: sudo-users at sudo.ws
> Subject: Using sudo in scripts
> This may sound like a basic question, but I have not been able to find
> an answer anywhere.
> Here is my scenario:
> I need to give "userA" sudo access to a menu driven script. The menu
> driven script will execute other system commands (i.e. cpio, tar, mt).
> If the user executes the script (using sudo), will all of the other
> commands (cpio, tar, mt....) be executed with sudo prefixed, or will I
> need to prefix every command with sudo into the script?
> Any help or guidance is greatly appreciated!
> sudo-users mailing list <sudo-users at sudo.ws>
> For list information, options, or to unsubscribe, visit:
More information about the sudo-users