[plug] script help, needed on 'su' or equivalent
Russell Steicke
r.steicke at bom.gov.au
Fri May 7 11:56:04 WST 2004
On Fri, May 07, 2004 at 11:46:58AM +0800, John Knight wrote:
> G'day all!
>
> I'm working on a script which I've dubbed 'buildprogram' for the moment. It
> takes:
> ./configure
> make
> su
> make install
>
> and whacks 'em all in a script so you only have to run the one command. Of
> course it's very basic at the moment, and I plan to add features like
> passing arguments to configure, error checking, etc. The main goal is to
> have one executable that I can run easily enough, and when I'm on a
> filemanager, ru nmy own little plugin where I go into a recently extracted
> tarball's directory, right click and choose 'make program here', at which
> point a terminal will open displaying the output and everything will make
> me happy. :)
>
> Anyway, the bit I'm not sure about is how do I run a command as root? The
> only think I know how to do is use su, and if you have 'su' and then 'make
> install' in the script, then it won't run the command. I know it's an easy
> question and probably an easy thing to do, but could someone please fill me
> ni on the right command?
sudo is a better choice for what you want to do. Run visudo as root to
edit the /etc/sudoers file. The man page for sudoers(5) is complete,
but cryptic. The simplest solution is to copy the line that says
root ALL=(ALL) ALL
and change the username. visudo will warn you after it leaves the
editor if you make a syntax mistake. You can restrict the commands that
a user is allowed to execute with sudo. Read the man page for details.
Then, in your script, remove the su line, and change "make install" with
sudo make install
--
Russell Steicke
-- Fortune says:
When a girl can read the handwriting on the wall, she may be in the wrong
rest room.
More information about the plug
mailing list