Computing.Net > Forums > Unix > Change of user in a script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Change of user in a script

Reply to Message Icon

Name: vicchai
Date: June 19, 2005 at 07:25:45 Pacific
OS: HPUX
CPU/Ram: Nil
Comment:

Hi,

I am in root user running a script, this script need to execute some commands in oracle user, eg:

#Start of script
...
(commands run in root user)
...
su - oracle #change to oracle user
(commands need to run in oracle user)
...
...
#end of script

My problem is when this script execute till the "su - oracle" it will pause at there point, when I enter "exit" then it continue to execute the next command after the "su - oracle" in root user, so how can I execute those commands in oracle user? Thanks for any help.




Sponsored Link
Ads by Google

Response Number 1
Name: cislord
Date: June 19, 2005 at 20:32:21 Pacific
Reply:

Remove all the commands that need to be run as oracle and place them in a different script, say called ora_commands.sh

In your main script, when you get to the point where you need to run these commands, try :
su oracle -c ora_commands.sh

You might have to call .profile (in Korn shell) for oracle in ora_commands.sh to set the environment variables,etc


0

Response Number 2
Name: vicchai
Date: June 20, 2005 at 06:59:56 Pacific
Reply:

Hi cislord,

Thanks, it works.


0

Response Number 3
Name: jamesl
Date: June 22, 2005 at 08:41:21 Pacific
Reply:


Or you can exec the application as oracle within your root script as follows:

root stuff

su oracle -c "xxxxxxx"
su oracle -c "yyyyyyy"

root stuff



0

Response Number 4
Name: vicchai
Date: June 23, 2005 at 06:58:45 Pacific
Reply:

Hi James,

What do you means this "xxxxxxx" and "yyyyyyy" ? Can you give an example?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Change of user in a script

users in a group www.computing.net/answers/unix/users-in-a-group/4868.html

Awk in a script www.computing.net/answers/unix/awk-in-a-script/6027.html

Change user in script www.computing.net/answers/unix/change-user-in-script/6574.html