Operating System - HP-UX
1834185 Members
2828 Online
110064 Solutions
New Discussion

Re: su - user -c < executable script/command >

 
SOLVED
Go to solution
Prashant Zanwar_3
Occasional Contributor

su - user -c < executable script/command >

Hi,

EAI processes in my system used to start with root owner at startup. I want the same processes to start under prodeai2 user rather than with root owner. What way I shall use to make it working using same startup script. Please reply,

Regards
Prashant
3 REPLIES 3
Jean-Luc Oudart
Honored Contributor
Solution

Re: su - user -c < executable script/command >

in your startup script something like (for start, adapt for stop) :
'start') /usr/bin/su - prodeai2 -c "//bin/ start" >>
/var/tmp/prodeai2.log 2>&1

This is an example.
You may want to add some test before you run the start command

Regards,
Jean-Luc
fiat lux
John Palmer
Honored Contributor

Re: su - user -c < executable script/command >

You've got the right idea in your subject line:-

su prodeai2 -c 'command args'

is the way to go.

Note that su - is not recommended because the profile scripts for that user get run and programs like stty can give you problems.

If you need to run the .profile in order to set up an environment (exported variables PATH etc) then write a suitable app_env script that .profile and any other script can run as a subshell.

Regards,
John
Prashant Zanwar_3
Occasional Contributor

Re: su - user -c < executable script/command >

Thanks for inputs provided. I have done it.