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???
ICPooremanAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
amit_gConnect With a Mentor Commented:
Or you can use

su root -c "./mycommand args"
0
 
amit_gCommented:
Use

sudo ./mycommand args
0
 
ravenplCommented:
In fact some su are more restrictive about parameters and requires username as last param, try then
su -c "./mycommand arg arg" root
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.