[CLUE-Tech] set user id of script

Jed S. Baer thag at frii.com
Thu Jun 6 11:44:15 MDT 2002


On Thu, 6 Jun 2002 11:23:11 -0600
Dave Price <davep at kinaole.org> wrote:

> Hi,
> 
> Is there a 'nice' way to execute a line in a script (or a script at
> startup under the priveleges of another user ... 
> 
> I need to run some oracle scripts as different oracle uids which have
> appropriate priveleges ...

Dave, you can use the su command (as root) to run commands as anybody. You
might notice this technique on your system now as the standard Oracle
startup/shutdown procedure. (The invocation of /usr/local/bin/dbstart in -
sheese, I need to get on an Oracle machine again - memory isn't working
today.)

For example, I use this command on my box to bring up the MySQL server as
user "mysql".

  su - mysql -c /usr/bin/safe_mysqld &

The first hyphen says to run the login environment, then -c "command". You
need the first hyphen so that stuff like $ORACLE_HOME, $ORACLE_SID, and
$PATH are set for the Oracle operations. You could export those
beforehand, I suppose. Since it runs as a subshell, I think it will
inherit them - I've never done it that way though. It's less maintenance
to just let the command pick up what it needs from oraenv.

BTW, if you need some more help, Oracle is my thang, ya know.

Later,
jed
-- 
We're frogs who are getting boiled in a pot full of single-character
morphemes, and we don't notice. - Larry Wall; Perl6, Apocalypse 5



More information about the clue-tech mailing list