Link to home
Start Free TrialLog in
Avatar of ICPooreman
ICPooreman

asked on

su user -c command -args doesn't accept arguments

I'm new with shell scripting so I may be missing something easy.  I'm writing a shell script which I want to su to a different user in my case the root user.  The problem is that when I do that it takes control away from the script.  Basically all I need to do is run one command as the root user so I decided I could write

su root -c ./mycommand args

which doesn't take control away from the script however mycommand now doesn't get the args I pass it.  What can I do to fix this???
Avatar of amit_g
amit_g
Flag of United States of America image

Use

sudo ./mycommand args
ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In fact some su are more restrictive about parameters and requires username as last param, try then
su -c "./mycommand arg arg" root