[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: using SUDO in bash script



Adam Aube wrote:

> On Wednesday 04 February 2004 03:23 pm, Rick Weinbender wrote:
> > Can I use SUDO within a bash script?
>
> Absolutely, though be aware that if sudo is set to require a password, you
> won't be able to run it in the background.
>
> By putting NOPASSWD before the command in /etc/sudoers, sudo will not
> require a password to run that command.
>

*****

Thanks.
I'm new to SUDO, but I found a web clip that seems to be
what I'm going for.  Just can't make it work yet.
Can I avoid typing sudo before myprogram at the commandline?

Clip Below:
*****************************************
Clipped from article:
"The one disadvantage of using sudo is that your users have to
 remember to run "sudo ..." as part of their command.  However,
 that's easy to work around by simply creating a wrapper shell
 script.  This is a normal (non-SUID) shell script that simply does
 something like:"
``
#!/bin/sh
exec /usr/bin/sudo /some/path/to/our/target/prog "$@"
''
 (execute sudo, on the target program and pass our argument,
 preserving any quoting as we specified it).
*****************************************

Thanks,
-Rick




Reply to: