[svlug] script commands requiring root access

Rafael raffi at ark.linwin.com
Thu Jan 17 23:03:02 PST 2002


On Thu, Jan 17, 2002 at 10:30:00PM -0800, Todd G. Gardner wrote:
> Hello,
> 
> I believe I am running the bash shell.  A script that I run requires

You beter know what shell you are using.

> root access.  I would like that script to automatically su - root in the
> script.  If I put su - root or su -m root it does not run the rest of 
> the script until I exit from the root session.

Good.

> 
> How do I run commands that require root access from a script without
> manually typing su - root?

Try using expect.

However, I would not run anything like that on public server. Anybody that 
breaks into your user space can and will gain control of the whole system.

A better way IMO is to have root monitor for some lock file created by the
user then run it's own script/program to take care of whatever needs to be
taken care of by the root. It will give you more control over what's going
on on your system and a bit more security.

> 
> Thank you,
> 
> Todd

-- 
Rafael




More information about the svlug mailing list