Operating System - HP-UX
1833875 Members
1656 Online
110063 Solutions
New Discussion

su - username -c command_name

 
Osama88
Occasional Advisor

su - username -c command_name

Hi all,

I am running HP-UX 11 and on my machine the above does not work.

This is what I did
su - oracle -c dbstart and su - oracle -c ls

All that the above did was to switch-user to oracle. The command were never executed.
Please help
7 REPLIES 7
Printaporn_1
Esteemed Contributor

Re: su - username -c command_name

Hi,

For me it work (HP-UX 11.0)

Does switch to other new created user work ?
enjoy any little thing in my life
Hartmut Lang
Trusted Contributor

Re: su - username -c command_name

Check which shell is used for your user "oracle".
Check if this shell can be called with "-c command".
Check if there are any errors during starting up the shell-environment for your user "oracle".
May be you need to check "man security".

Hardy
Steve Steel
Honored Contributor

Re: su - username -c command_name

Hi

Check your .profile for something like

exec sh

A fork to a new level will mean no command


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Kenny Chau
Trusted Contributor

Re: su - username -c command_name

Hi Mike,

First of all, which account you use to run this command? root? or superusers? If not, maybe you can not su to other accounts without password.
Second, what error messages you've got while running this command? Please post the error messages so that we can trace your problem.

Regards,
Kenny.
Kenny
Heidl Robert
Occasional Advisor

Re: su - username -c command_name

Hi Mike,
try "su oracel -c ls" (without minus).
It doesn't read the .profile.
Hope it helps.
Robert
Sanjay_6
Honored Contributor

Re: su - username -c command_name

Hi Mike,

Try this,

su - user_name -c "type your command here"

Hope this helps.

Regds
Tim Woods_2
Advisor

Re: su - username -c command_name

Mike,

I'm doing something similar right now. You will probably have to do as Robert suggested and use

su oracle instead of su - oracle

so it doesn't read the profile. If it still gives you problems, create a script with the oracle user's environment variables in it with the dbstart command after, and then run this from the command line. Something like

su oracle -c myscript.sh

Let us know how it works.

Tim